Gigacore
Dreamweaver
Re: Post ur C/C++ Programs Here
A C program to find the maximum and minimum elements in an array having N elements
}
A C program to find the maximum and minimum elements in an array having N elements
Code:
#include <stdio.h>
main()
{
int a [100]; /* Array Declaration */
int i,n,max,mini;
printf("Enter number of elements in the array");
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
max=a[0];
mini=a[0];
for(i=1;i<n;i++)
{
if(max<a[i])max=a[i];
if(mini>a[i])mini=a[i];
}
printf("\nMaximum element in the array is %d",max);
printf("\nMinimum element in the array is %d",mini);
return 0;