Follow This Blog For more... 😊

Program to accept roll number and marks of three subjects from user and print total marks, average and grade.| Using C language| C Program series 13|

👨‍💻Program to accept roll number and marks of three subjects from the user and print total marks, average, and grade.

Code:


    //Program to accept roll number and marks of three subjects from the user and print total marks, average, and grade.
    #include<stdio.h>
    main()
    {
        printf("Program to accept roll number and marks(out of 100) of three subjects from the user and print total marks, average & grade.\n\n");
       
        int rollnumber;
        float mark1,mark2,mark3,total,average;
       
        printf("Enter the Student's Roll no.:");
        scanf("%d",&rollnumber);
        printf("Enter the subject-1's MARKS :");
        scanf("%f",&mark1);
        printf("Enter the subject-2's MARKS :");
        scanf("%f",&mark2);
        printf("Enter the subject-3's MARKS :");
        scanf("%f",&mark3);
       
        total=mark1+mark2+mark3;
        average=total/3;
       
        printf("TOTAL:%.1f/300.0\n",total);
        printf("AVERAGE(PERCENTAGE):%.2f\n",average);
       
       
        if(average>80)
        {
            printf("GRADE:A (PASS)");
        }
        else if(average>60&&average<=80)
        {
            printf("GRADE:B (PASS)");
        }
        else if(average>40&&average<=60)
        {
            printf("GRADE:C (PASS)");
        }
        else if(average>=33&&average<=40)
        {
            printf("GRADE:D (PASS)");
        }
        else
        {
            printf("GRADE:E (FAIL)");
        }
    }

Output:




👉Click for more C Program series Questions.[Questions list]

Comments

Popular Posts