Maximum of an array
shebom640
c_cpp
2 years ago
514 B
13
Indexable
// write a program to find max of an array
#include <stdio.h>
int main()
{
int n, i;
printf("Enter size of an array\n");
scanf("%d", &n);
int a[n];
printf("Enter array elements \n");
for(i =0; i<n; i++)
{
printf("Enter %d element: ", i+1);
scanf("%d", &a[i]);
}
int max = a[0];
for(i=0; i<n; i++) {
if(max < a[i])
{
max = a[i];
} else {
continue;
}
}
printf("Max is %d", max);
return 0;
}Editor is loading...