#include<stdio.h>
void main()
{
int a[100];
int n,f,s,i;
printf("enter the number of elements in the array at least 2 \n");
scanf("%d",&n);
printf(" \n enter the elements and press enter\n");
for(i=0;(i<n);i++)
{
scanf("%d",&a[i]);
if(a[i]>f)
f=a[i];
else if(a[i]<s)
s=a[i];
}
printf("%d is the first largest number \n",f); printf("%d is the smallest number \n",s);
}
/*sample output is shown in the screen shot*/
No comments:
Post a Comment