TALLER CORN
Problem Description
Rakshan had a bowl of corns. He is eating the huge corn followed by little corn. For that he has to find large and small corns to eat. Consider numbers instead of corns. Can you find the largest and smallest one?
- CODING ARENA::
#include <stdio.h>
int main()
{
int a,i,l,s;
scanf("%d",&a);
int b[a];
for(i=0;i<a;i++)
{
scanf("%d",&b[i]);
}
l=b[0];
for(i=1;i<a;i++)
{
if(l<b[i])
{
l=b[i];
}
}
s=b[0];
for(i=0;i<a;i++)
{
if(s>b[i])
s=b[i];
}
printf("%d",l);
printf("\n%d",s);
return 0;
}
Test Case 1
Input (stdin)5
1 8 9 7 5
Expected Output
9
1
Test Case 2
Input (stdin)4
9 19 7 8
Expected Output
19
7
No comments:
Post a Comment