Coding | Mcqs | Multiple choice questions | Informative | Computer Science | Engineering | Aptitude | Quants | Verbal

INFEED

C - VERY-EASY - PART005-Largest among N numbers

 Number N is passed as the input. The program must accept N integer values and print the largest number L among these N numbers.

Input Format:
The first line denotes the value of N.
The next N lines denote the value of N numbers.

Output Format:
The first line denotes the value of L.

Boundary Conditions:
1 <= N <= 50

Example Input/Output 1:
Input:
3
100
200
40

Output:
200

Example Input/Output 2:
Input:
5
18
500
70
30
999

Output:
999

Code:

#include<stdio.h>
#include<stdlib.h>

int main()
{int a,sum=0;
scanf("%d",&a);
for(int i=0;i<a;i++)
{
int b;scanf("%d",&b);
if(sum<b)
sum=b;
}
printf("%d",sum);
}

Post a Comment

Previous Post Next Post