-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1-D-array.c
36 lines (18 loc) · 811 Bytes
/
1-D-array.c
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
//In this program, we declare a one-dimensional array percentages with a size of 10 to store the percentages of the students. We then use a for loop to input the percentages of 10 students, and another for loop to display the percentages of 10 students. The %.2f%% format specifier is used to display the percentages with two decimal places and a percent sign.
#include <stdio.h>
int main() {
float percentages[10];
int i;
printf("Enter the percentages of 10 students:\n");
// Input the percentages of 10 students
for (i = 0; i < 10; i++) {
printf("Student %d: ", i + 1);
scanf("%f", &percentages[i]);
}
// Display the percentages of 10 students
printf("Percentages of 10 students:\n");
for (i = 0; i < 10; i++) {
printf("Student %d: %.2f%%\n", i + 1, percentages[i]);
}
return 0;
}