PPS Practical 22

PPS Practical 22
  • Aim: Write a program to calculate average and total of 5 students for 3 subjects (use nested for loops).
  • Code:
    //For turbo C++ remove below comments
    #include <stdio.h>
    //#include<conio.h>
    void main()
    {
        int student,subject,marks;
        float sum=0;
        // clrscr();
        for (student = 0; student < 5; student++){
            sum=0;
            printf("Student %d\n",student+1);
            for (subject = 0; subject < 3; subject++){
                printf("Enter marks for subject %d :",subject+1);
                scanf("%d",&marks);
                sum+=marks;
            }
            printf("Sum : %.2f\n",sum);
            printf("Average : %.2f\n\n",(float)(sum/3));
        }
        // getch();
    }
  • Output:
  • Output of practical 22

Comments