Sita has been promoted to a Team Leader and she has been shifted to Multimedia Team.  As she needs to extensively work on audio, image and video signals, she is planning to spend a day in mastering the basics of 1-D and 2-D arrays.
Can you please help her out?
Write a  program to find the maximum element in an array. 
Input Format:
Input consists of n+1 integers.
The first line of the input contains an integer corresponds to ‘n’, the size of the array.
The next ‘n’ integers correspond to the elements in the array. Assume that the maximum value of n is 15.
Output Format:
Refer sample input and output for formatting details.
Sample Input 1:
5
2
3
6
8
1
Sample Output 1:
8 is the maximum element in the array


Program Code:
#include<stdio.h>
int main()
int i,n=0,a;
 scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a);
if(n<a)
{
 n=a;
}
}
printf("%d is the maximum element in the array",n);
return 0;
}
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: