-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathlargest.c
More file actions
39 lines (30 loc) · 726 Bytes
/
largest.c
File metadata and controls
39 lines (30 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*********
Author1 Name:
Author2 Name:
FIXED THE BUGS FOR GIT-WORKSHOP
**********/
#include <stdio.h>
int main()
{
int i, n;
float arr[100];
printf("Enter total number of elements(1 to 100): ");
scanf("%d", &n);
printf("\n");
// Stores number entered by the user
for(i = 0; i < n; ++i)
{
printf("Enter Number %d: ", i+1);
// HERE IS THE BUG, PUT '&' IN FRONT OF arr[i]
scanf("%f", arr[i]);
}
// Loop to store largest number to arr[0]
for(i = 1; i < n; ++i)
{
// Change < to > if you want to find the smallest element
if(arr[0] < arr[i])
arr[0] = arr[i];
}
printf("Largest element = %.2f", arr[0]);
return 0;
}