Learn C ProgrammingLearn ProgrammingPrograms On Arithmetic OperatorsResources

011. Write a program to accept roll no and marks of 3 subjects of a student, Calculate total of 3 subjects and average in C language

By September 18, 2012 February 5th, 2018 6 Comments
  1. #include<stdio.h>
  2. #include<conio.h>
  3. main()
  4. {
  5. int roll_no,m1,m2,m3,total;
  6. float average;
  7. clrscr();
  8. printf("Enter roll number : ");
  9. scanf("%d",&roll_no);
  10. printf("Enter marks 1 : ");
  11. scanf("%d",&m1);
  12. printf("Enter marks 2 : ");
  13. scanf("%d",&m2);
  14. printf("Enter marks 3 : ");
  15. scanf("%d",&m3);
  16. total=m1+m2+m3;
  17. average=total/3.0;
  18. printf("\nStudent Roll Number : %d",roll_no);
  19. printf("\nMarks 1 : %d",m1);
  20. printf("\nMarks 2 : %d",m2);
  21. printf("\nMarks 3 : %d",m3);
  22. printf("\nTotal : %d ",total);
  23. printf("\nAverage : %f ",average);
  24. getch();
  25. }
#include<stdio.h> 
#include<conio.h>  
main()
{
  int roll_no,m1,m2,m3,total;
  float average;
  clrscr();
  printf("Enter roll number : ");
  scanf("%d",&roll_no);
  printf("Enter marks 1 : "); 
  scanf("%d",&m1);
  printf("Enter marks 2 : ");
  scanf("%d",&m2);
  printf("Enter marks 3 : ");
  scanf("%d",&m3);
  total=m1+m2+m3;
  average=total/3.0;
  printf("\nStudent Roll Number : %d",roll_no);
  printf("\nMarks 1 : %d",m1);
  printf("\nMarks 2 : %d",m2);
  printf("\nMarks 3 : %d",m3);
  printf("\nTotal : %d ",total);
  printf("\nAverage : %f ",average);
  getch();
}

6 Comments

Leave a Reply

DEMO01