#include <stdio.h>
int i, num, gpa, GPAFreq[4];
printf ("Enter the number of students: "); if (num <= 0) {
return 0;
}
for (i=1; i <=num ; i++) {
printf ("GPA of student #%d is: ", i
); switch (gpa) {
case 1: GPAFreq[0]++; break;
case 2: GPAFreq[1]++; break;
case 3: GPAFreq[2]++; break;
case 4: GPAFreq[3]++; break;
default: printf ("Invalid number! \n"); i
--; break; }
}
printf ("The total number of student is %d.\n", num
); printf ("GPA 1 --- %d student(s)\n", GPAFreq
[0]); printf ("GPA 2 --- %d student(s)\n", GPAFreq
[1]); printf ("GPA 3 --- %d student(s)\n", GPAFreq
[2]); printf ("GPA 4 --- %d student(s)\n", GPAFreq
[3]);
return 0;
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgaSwgbnVtLCBncGEsIEdQQUZyZXFbNF07CiAgIHByaW50ZiAoIkVudGVyIHRoZSBudW1iZXIgb2Ygc3R1ZGVudHM6ICIpOwogICBzY2FuZiAoIiVkIiwgJm51bSk7CiAgIGlmIChudW0gPD0gMCkgewogICAgICBwcmludGYgKCJJbnZhbGlkIG51bWJlciFcbiIpOwogICAgICByZXR1cm4gMDsgCiAgIH0KICAgZm9yIChpPTE7IGkgPD1udW0gOyBpKyspIHsKICAgICAgcHJpbnRmICgiR1BBIG9mIHN0dWRlbnQgIyVkIGlzOiAiLCBpKTsKICAgICAgc2NhbmYgKCIlZCIsIGdwYSk7CiAgICAgIHN3aXRjaCAoZ3BhKSB7CiAgICAgICAgIGNhc2UgMTogR1BBRnJlcVswXSsrOyBicmVhazsKICAgICAgICAgY2FzZSAyOiBHUEFGcmVxWzFdKys7IGJyZWFrOwogICAgICAgICBjYXNlIDM6IEdQQUZyZXFbMl0rKzsgYnJlYWs7CiAgICAgICAgIGNhc2UgNDogR1BBRnJlcVszXSsrOyBicmVhazsKICAgICAgICAgZGVmYXVsdDogcHJpbnRmICgiSW52YWxpZCBudW1iZXIhIFxuIik7IGktLTsgYnJlYWs7ICAgCiAgICAgIH0KICAgfQogICAKICAgcHJpbnRmICgiVGhlIHRvdGFsIG51bWJlciBvZiBzdHVkZW50IGlzICVkLlxuIiwgbnVtKTsKICAgcHJpbnRmICgiR1BBIDEgLS0tICVkIHN0dWRlbnQocylcbiIsIEdQQUZyZXFbMF0pOwogICBwcmludGYgKCJHUEEgMiAtLS0gJWQgc3R1ZGVudChzKVxuIiwgR1BBRnJlcVsxXSk7CiAgIHByaW50ZiAoIkdQQSAzIC0tLSAlZCBzdHVkZW50KHMpXG4iLCBHUEFGcmVxWzJdKTsKICAgcHJpbnRmICgiR1BBIDQgLS0tICVkIHN0dWRlbnQocylcbiIsIEdQQUZyZXFbM10pOwogICAKICAgcmV0dXJuIDA7Cg==
prog.c:4:12: error: expected declaration specifiers or ‘...’ before string constant
printf ("Enter the number of students: ");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.c:5:11: error: expected declaration specifiers or ‘...’ before string constant
scanf ("%d", &num);
^~~~
prog.c:5:17: error: expected declaration specifiers or ‘...’ before ‘&’ token
scanf ("%d", &num);
^
prog.c:6:4: error: expected identifier or ‘(’ before ‘if’
if (num <= 0) {
^~
prog.c:10:4: error: expected identifier or ‘(’ before ‘for’
for (i=1; i <=num ; i++) {
^~~
prog.c:10:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<=’ token
for (i=1; i <=num ; i++) {
^~
prog.c:10:25: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘++’ token
for (i=1; i <=num ; i++) {
^~
prog.c:22:12: error: expected declaration specifiers or ‘...’ before string constant
printf ("The total number of student is %d.\n", num);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.c:22:52: error: expected declaration specifiers or ‘...’ before ‘num’
printf ("The total number of student is %d.\n", num);
^~~
prog.c:23:12: error: expected declaration specifiers or ‘...’ before string constant
printf ("GPA 1 --- %d student(s)\n", GPAFreq[0]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.c:23:41: error: expected declaration specifiers or ‘...’ before ‘GPAFreq’
printf ("GPA 1 --- %d student(s)\n", GPAFreq[0]);
^~~~~~~
prog.c:24:12: error: expected declaration specifiers or ‘...’ before string constant
printf ("GPA 2 --- %d student(s)\n", GPAFreq[1]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.c:24:41: error: expected declaration specifiers or ‘...’ before ‘GPAFreq’
printf ("GPA 2 --- %d student(s)\n", GPAFreq[1]);
^~~~~~~
prog.c:25:12: error: expected declaration specifiers or ‘...’ before string constant
printf ("GPA 3 --- %d student(s)\n", GPAFreq[2]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.c:25:41: error: expected declaration specifiers or ‘...’ before ‘GPAFreq’
printf ("GPA 3 --- %d student(s)\n", GPAFreq[2]);
^~~~~~~
prog.c:26:12: error: expected declaration specifiers or ‘...’ before string constant
printf ("GPA 4 --- %d student(s)\n", GPAFreq[3]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.c:26:41: error: expected declaration specifiers or ‘...’ before ‘GPAFreq’
printf ("GPA 4 --- %d student(s)\n", GPAFreq[3]);
^~~~~~~
prog.c:28:4: error: expected identifier or ‘(’ before ‘return’
return 0;
^~~~~~