Greatest among input ‘n’ numbers using Array in C Program

/*Greatest in array*/
#include <stdio.h>
int main()
{
int i, n;
float arr[100],max;
printf("Enter the number of elements (1 to 100): ");
scanf("%d", &n);
for (i = 0; i < n; i++)
{
printf("Enter number%d:", i+1);
scanf("%f", &arr[i]);
}
max=arr[0];

for (i =0; i < n; i++)
{
if (max < arr[i])
max= arr[i];
}
printf("Largest element = %.8f", max);
}

Leave a Reply

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

Enter Captcha Here : *

Reload Image