Arrays

Program to find the maximum no. of a given array:

#include<stdio.h>
#include<conio.h>
void main()
{
	int i,j,size,max;
	printf("enter the length of  the array:");
	scanf(" %d",&size);
	int array[size];
	printf("enter the array:");
	for(i=0;i<size;i++)
	{
		scanf("%d",array[i]);
	}
	max=array[0];
	for(i=1;i<size;i++)
	{
		if(array[i]>max)
		{
			max=array[i];
		}
	}
	printf("max=%d",max);
	getch();

}

Leave a comment