Dain1234 / Design-and-analysis-algorithm

0 stars 0 forks source link

largest number in an array #18

Open Dain1234 opened 2 years ago

Dain1234 commented 2 years ago

include

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]); } for (int i = 1; i < n; ++i) { if (arr[0] < arr[i]) { arr[0] = arr[i]; } }

printf("Largest element = %.2lf", arr[0]);

return 0; }