Write a program to read 10 array of integers and find the smallest numbers
#include<stdio.h> int main() { int a[10],i,largest,smallest; printf("Enter array element: \n"); for(i=0;i<10;i++){ scanf("%d",&a[i]); } largest=a[0]; smallest=a[0]; for(i=1;i<10;i++) { if(largest<a[i]) largest=a[i]; else if(smallest>a[i]) smallest=a[i]; } printf("Largest = %d\n",largest); printf("Smallest = %d",smallest); return 0; }
Output
Enter array element:
1
2
4
5
7
8
9
0
44
5
Largest = 44
Smallest = 0