Â
In this, we are going to print the largest number among the array elements by taking input from user in C Programming Language.
#include <stdio.h>
int main()
{
int n;
double arr[100];
printf("Enter the number of elements (1 to 100): ");
scanf("%d", &n);
for (int i = 0; i < n; ++i)
{
printf("Enter number%d: ", i + 1);
scanf("%lf", &arr[i]);
}
// storing the largest number to arr[0]
for (int i = 1; i < n; ++i)
{
if (arr[0] < arr[i])
{
arr[0] = arr[i];
}
}
printf("Largest element = %.2lf", arr[0]);
return 0;
}
//.......Coded By JAIDEEP JAMBHALE
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP