Find the Height & Lowest value from a give array
#include<stdio.h>
int main ()
{
int i,n;
int a[100];
printf("Enter the array size: ");
scanf("%d",&n);
for(i = 0; i < n; i++)
{
printf("\n Enter %d value: ",i+1);
scanf("\n %d", &a[i]);
}
int max = a[0];
int min = a[0];
for (i = 0; i <n; i++)
{
if (a[i] > max)
{
max = a[i];
}
else if (a[i] < min)
{
min = a[i];
}
}
printf ("Maximum element in an array : %d\n", max);
printf ("Minimum element in an array : %d\n", min);
return 0;
}
#include<stdio.h>
int main ()
{
int i,n;
int a[100];
printf("Enter the array size: ");
scanf("%d",&n);
for(i = 0; i < n; i++)
{
printf("\n Enter %d value: ",i+1);
scanf("\n %d", &a[i]);
}
int max = a[0];
int min = a[0];
for (i = 0; i <n; i++)
{
if (a[i] > max)
{
max = a[i];
}
else if (a[i] < min)
{
min = a[i];
}
}
printf ("Maximum element in an array : %d\n", max);
printf ("Minimum element in an array : %d\n", min);
return 0;
}
No comments:
Post a Comment