Program:
#include<stdio.h>
int main()
{
int num[10],i,max=0,min=0,n;
printf("Enter no. of elements: "); /* within array size*/
scanf("%d",&n);
printf("Enter %d numbers:\n",n);
for(i=0;i<n;i++)
{
scanf("%d",&num[i]);
if(num[i]>max)
{
max=num[i];
}
if(num[i]<min)
{
min=num[i];
}
}
printf("Maximum = %d \nMinimum = %d",max,min);
return 0;
}
Output:
#include<stdio.h>
int main()
{
int num[10],i,max=0,min=0,n;
printf("Enter no. of elements: "); /* within array size*/
scanf("%d",&n);
printf("Enter %d numbers:\n",n);
for(i=0;i<n;i++)
{
scanf("%d",&num[i]);
if(num[i]>max)
{
max=num[i];
}
if(num[i]<min)
{
min=num[i];
}
}
printf("Maximum = %d \nMinimum = %d",max,min);
return 0;
}
Output:
No comments:
Post a Comment