Print total marks using do while - C Program

Write a C program to read marks of five subjects of student and print total marks using do while loop.

Solution:

#include<stdio.h>
int main()
{
      int n=1,marks,s=0;
      printf("/*Enter Marks of Student\nfor 5-Subjects*/\n");
      do
      {
            printf("\n Subject-%d : ",n);
            scanf("%d",&marks);
            s=s+marks;
            n++;
      }while(n<=5);
      printf("-------------------------");
      printf("\n Total Marks : %d\n",s);
      return 0;
}


Output:

print total marks