Sita has been promoted as 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?
Maximum Element in an Array
Input Format:
Input consists of n+1 integers. The first 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 output for details.
Sample Input 1:
5
2
3
6
8
1
Sample Output 1:
8 is the maximum element in the array
Code:
#include<stdio.h> int main(){ int n,max=0,i,a[20]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); if(a[i]>max) max=a[i]; } printf("%d is the maximum element in the array",max); return 0; }
What's the code for finding maximum element in an array using function..?
ReplyDeleteNice way to find element in array. there is also good way to find element in array Find max element in array
ReplyDeleteNice way to find element in array. there is also good way to find element in array Find max element in array
ReplyDelete