Array:
collection of same data type.
-We have to find the maximum in integer array.
Example-
array is {1,2,3,6,0,34,21}
then maximum is 34
program-
#include < stdio.h>
int main()
{
int a[20],i,max;
printf("Enter 10 number in array\n");
for(i=0;i< 10;i++)
scanf("%d",&a[i]);
max=a[0];
for(i=1;i< 10;i++)
{
if(a[i]>max)
max=a[i];
}
printf("Maximum number in array is %d",max);
}
output-
Enter 10 number in array
1 2 3 4 5 6 7 8 9 0
Maximum number in array is 9
-In this program, we create a array with max size 20, but we take an input of 10 numbers in array.
-Then we take first number as a maximum and check other elements,if any other element is greator then max then assign number to max and continue this process until loop finish.