fork download
  1. #include <stdio.h>
  2.  
  3. int i, num, gpa, GPAFreq[4];
  4. printf ("Enter the number of students: ");
  5. scanf ("%d", &num);
  6. if (num <= 0) {
  7. printf ("Invalid number!\n");
  8. return 0;
  9. }
  10. for (i=1; i <=num ; i++) {
  11. printf ("GPA of student #%d is: ", i);
  12. scanf ("%d", gpa);
  13. switch (gpa) {
  14. case 1: GPAFreq[0]++; break;
  15. case 2: GPAFreq[1]++; break;
  16. case 3: GPAFreq[2]++; break;
  17. case 4: GPAFreq[3]++; break;
  18. default: printf ("Invalid number! \n"); i--; break;
  19. }
  20. }
  21.  
  22. printf ("The total number of student is %d.\n", num);
  23. printf ("GPA 1 --- %d student(s)\n", GPAFreq[0]);
  24. printf ("GPA 2 --- %d student(s)\n", GPAFreq[1]);
  25. printf ("GPA 3 --- %d student(s)\n", GPAFreq[2]);
  26. printf ("GPA 4 --- %d student(s)\n", GPAFreq[3]);
  27.  
  28. return 0;
  29.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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;
    ^~~~~~
stdout
Standard output is empty