i have done program as below. need to input no of students and no of subject.
no of subject and student is undefine. every entered marks should produce its grade.

in this case i've defined the no of subject by right it should be entered by user. how can i edit this to looks like this

enter no of student :
enter no of subject :

enter student id:
mark for id is:

#include <stdio.h>

void main(){
     float average,total_mark;
     int noStud, StudID, noSub;
     int num1, num2 , num3;
     
     printf("\t\t\tGrading System\n\n");
     printf("Enter no. of student: ");
     scanf("%d", &noStud);
     printf("Enter no of subject: ");
     scanf("%d", &noSub);
     printf ("\n\n\t>>Enter students ID:");
     scanf ("%d" , &StudID );
     printf ("\n\t>>Enter marks for %d:\n" , StudID );


     printf ("\tEnter mark for subject English: ", &num1);
     scanf("%i", &num1);
     if (num1 >= 80 && num1 <= 100)
     printf ("\tGrade: A\n");
     else if ((num1 >= 70 && num1 <=79))
     printf ("\tGrade: B\n");
     else if ((num1 >=60 && num1 <=69))
     printf ("\tGrade: C\n");
     else if ((num1 >= 50 && num1 <=59))
     printf ("\tGrade: D\n");
     else if ((num1 >= 40 && num1 <=49))
     printf ("\tGrade: E\n");
     else if ((num1 >=0 && num1 <=39))
     printf ("\tGrade: F\n");
     
     printf ("\tEnter mark for Mathematic: ", &num2);
     scanf("%i", &num2);
     if (num2 >= 80 && num2 <= 100)
     printf ("\tGrade: A\n");
     else if ((num2 >= 70 && num2 <=79))
     printf ("\tGrade: B\n");
     else if ((num2 >=60 && num2 <=69))
     printf ("\tGrade: C\n");
     else if ((num2 >= 50 && num2 <=59))
     printf ("\tGrade: D\n");
     else if ((num2 >= 40 && num2 <=49))
     printf ("\tGrade: E\n");
     else if ((num2 >=0 && num2 <=39))
     printf ("\tGrade: F\n");

     printf ("\tEnter mark for Science: ", &num3);
     scanf("%i", &num3);
     if (num3 >= 80 && num3 <= 100)
     printf ("\tGrade: A\n");
     else if ((num3 >= 70 && num3 <=79))
     printf ("\tGrade: B\n");
     else if ((num3 >=60 && num3 <=69))
     printf ("\tGrade: C\n");
     else if ((num3 >= 50 && num3 <=59))
     printf ("\tGrade: D\n");
     else if ((num3 >= 40 && num3 <=49))
     printf ("\tGrade: E\n");
     else if ((num3 >=0 && num3 <=39))
     printf ("\tGrade: F\n");

     total_mark=num1+num2+num3;
     printf ("\nTotal Marks = %.2f\n", total_mark);
     average=total_mark/noSub;
     printf ("Average Marks = %.2f\n" ,total_mark/noSub);
     if ( average  >= 40)
     printf ("PROCEED TO THE NEXT SEMESTER....\n");
     else if (average <=39)
     printf ("FAIL TO THE NEXT SEMESTER....\n");

     
     system("pause");
     return 0;

     
     
}

Edited 6 Years Ago by __avd: Added [code] tags.

Hello vanan4u

These are your errors
1) You have declared the return type of main as void but returned an integer. It is recommended to use int main(). See here
2) You have made a system call, however forgot to include the necessary header files for the function (stblib.h). However, system calls are not recommended. See here

It is recommended to use a function like char get_grade(int marks) instead of repeating it

line 18: printf ("\tEnter mark for subject English: ", &num1);
err:&num1 for the printf stmt why u use this without format specifier?

no return type for void.

#include <stdio.h>

     void Getgrade(int mark)
        {
        if (mark >= 80 && mark <= 100)
        printf ("\tGrade: A\n");
        else if ((mark >= 70 && mark <=79))
        printf ("\tGrade: B\n");
        else if ((mark >=60 && mark <=69))
        printf ("\tGrade: C\n");
        else if ((mark >= 50 && mark <=59))
        printf ("\tGrade: D\n");
        else if ((mark >= 40 && mark <=49))
        printf ("\tGrade: E\n");
        else if ((mark >=0 && mark <=39))
        printf ("\tGrade: F\n");
        else
        printf("\tInvalid Mark\n");
        printf ("\tGrade: C\n");
        else if ((mark >= 50 && mark <=59))
        printf ("\tGrade: D\n");
        else if ((mark >= 40 && mark <=49))
        printf ("\tGrade: E\n");
        else if ((mark >=0 && mark <=39))
        printf ("\tGrade: F\n");
        else
        printf("\tInvalid Mark\n");
        }

int main(){

     float average;
     int noStud,total_mark, StudID, noSub;
     int marks[10];
     int i,j;
     printf("\t\t\tGrading System\n\n");
     printf("Enter no. of student: ");
     scanf("%d", &noStud);
     printf("Enter no of subject: ");
     scanf("%d", &noSub);

     for(i =0; i < noStud; i++)
     {
     total_mark =0;
     average =0;
     printf ("\n\n\t>>Enter students ID:");
     scanf ("%d" , &StudID );
     printf ("\n\t>>Enter marks for %d:\n" , StudID );

     for(j =0; j < noSub; j++)
        {
     printf ("\tEnter mark for subject %d ", j+1);
     scanf("%d",&marks[j]);
     total_mark += marks[j];
        Getgrade(marks[j]);
        }

     printf ("\nTotal Marks = %d\n", total_mark);
     average=total_mark/noSub;
     printf ("Average Marks = %.2f\n" ,average);
     if ( average  >= 40)
     printf ("PROCEED TO THE NEXT SEMESTER....\n");
     else if (average <=39)
     printf ("FAIL TO THE NEXT SEMESTER....\n");

     }
   return 0;

How is it. I dont know you r close this or not!

Please, do not hijack threads. Start a separate thread instead.
As for your question, i'll be saying it in short. system("pause") creates a pause during a running program, which can be resumed by pressing any key. It("pause") is a Windows specific command and is generally not recommended

This article has been dead for over six months. Start a new discussion instead.