Search
 
SCRIPT & CODE EXAMPLE
 

C

find smallest number in array in c

#include<stdio.h>
 
int main() {
   int i, num, smallest;
 
   printf("
Enter no of elements :");
   scanf("%d", &num);
   int a[num];
   //Read n elements in an array
   for (i = 0; i < num; i++)
      scanf("%d", &a[i]);
 
   //Consider first element as smallest
   smallest = a[0];
 
   for (i = 0; i < num; i++) {
      if (a[i] < smallest) {
         smallest = a[i];
      }
   }
 
   // Print out the Result
   printf("
Smallest Element : %d", smallest);
 
   return (0);
}
Comment

PREVIOUS NEXT
Code Example
C :: c bit access union 
C :: what is strikethrough in markdown 
C :: c number to string 
C :: nested switch case in c 
C :: c/c++ type format 
C :: function for quicksort in c 
C :: c fork wait for child 
C :: c binary search 
C :: typedef pointer 
C :: Graphics in C Draw A Line 
C :: read string with space c 
C :: how to scanf two dimensional array in c 
C :: c int 
C :: pyramid using c 
C :: C scanf() to read a string 
C :: plt legend top right outside 
C :: measure time in c 
C :: c round float 
C :: fgets c 
C :: adjacency matrix representation maker 
C :: converting strings to numbers in c 
C :: Leap year using function in c 
C :: best approach c menu terminal 
C :: why do you jerk while falling aslee 
C :: print in c 
C :: c file struct 
C :: writing structures in c 
C :: C How to define a union? 
C :: columntransformer in randomizedsearchcv 
C :: how to belu-roll peoples in c 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =