070. Write a program to accept a number n from user and then accept n array elements from user and print maximum and minimum array element from that set of array in C language

#include<stdio.h>
#include<conio.h>
main()
{
	int n,i,a[20],max,min;
	clrscr();
	printf("Enter number : ");
	scanf("%d",&n);
	printf("Enter array elements...\n");
	for(i=0;i<n;i++)
	{
		printf("Enter element %d : ",i+1);
		scanf("%d",&a[i]);
	}
	max=min=a[0];
	for(i=0;i<n;i++)
	{
		if(a[i]>max)
			max=a[i];
if(a[i]<min)
			min=a[i];
	}
	printf("\nMin : %d",min);
	printf("\nMax : %d",max);
	getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *