Program to calculate sum,average and division of marks using else-if ladder in C Language

Introduction: In previous articles i explained the Program to calculate sum,average of marks and Else if ladder or multiple else if to check the day corresponding to number  and  How to find week days corresponding to number using switch case and Else if ladder or multiple else if to check the day corresponding to number  and Else if ladder or multiple else if to check the month of entered number and What is For loop in C language? Program to print counting up to given limit and What is goto statement in C language,its advantages and disadvantages with program example and Swap two numbers without using temporary variable and Find greatest of three numbers using nested if else statement

In this article i have written a program to calculate the total marks,average of marks and based on average, it calculates the division using else-if ladder or we can say multiple else-if.

Description: It will first prompt user to enter name,class,roll number and marks in each subject.Then it will calculate the total marks obtained,average of marks and division.

Implementation: Let's create a program to understand.

#include<conio.h>
#include<stdio.h>
main()
{
      char name[25];
      int roll,clas;
      float hindi,eng,math,sci,art,comp,total,avg;
      clrscr();
      printf("Enter name of student:=");
      scanf("%s",&name);
      printf("Enter class of student:=");
      scanf("%d",&clas);
      printf("Enter rollno of student:=");
      scanf("%d",&roll);
      printf("Enter marks in hindi:=");
      scanf("%f",&hindi);
      printf("Enter marks in english:=");
      scanf("%f",&eng);
      printf("Enter marks in math:=");
      scanf("%f",&math);
      printf("Enter marks in science:=");
      scanf("%f",&sci);
      printf("Enter marks in art:=");
      scanf("%f",&art);
      printf("Enter marks in computers:=");
      scanf("%f",&comp);
      total=hindi+eng+math+sci+art+comp;
      avg=total/6;
      printf("\n************Student's Marks Record*************\n");
      printf("Student's name=%s",name);
      printf("\nclass=%d",clas);
      printf("\nRoll No=%d",roll);
      printf("\nMarks in Hindi=%.0f",hindi);
      printf("\nMarks in English=%.0f",eng);
      printf("\nMarks in Math=%.0f",math);
      printf("\nMarks in Science=%.0f",sci);
      printf("\nMarks in Computer=%.0f",comp);
      printf("\nTotal Marks=%.0f",total);
      printf("\nAverage Marks=%.2f",avg);

if(avg>=80)
{
 printf("\n Merit");
}
else if(avg>=60)
 {
   printf("\n First Division");
 }
  else if(avg>=50)
   {
     printf("\n Second Division");
   }
    else if(avg>=35)
     {
printf("\n Pass");
     }
      else
      {
         printf("\n Fail");
      }
getch();
 }
  • Run the program using Ctrl+F9
Output:
Enter name of student:=Karan
Enter class of student:=12
Enter rollno of student:=18
Enter marks in hindi:=77
Enter marks in english:=67
Enter marks in math:=80
Enter marks in science:=75
Enter marks in arts=68
Enter marks in computer:=88

****************Student's Marks Record****************
Student's name:=Karan
Class:=12
Roll No:=18
Marks in Hindi:=77
Marks in English:=67
Marks in Math:=80
Marks in Science:=75
Marks in Art:=68
Marks in Computer:=88
Total Marks:=455
Average Marks:=75.83
First Division

Now over to you:
"If you like my work; you can appreciate by leaving your comments, hitting Facebook like button, following on Google+, Twitter, Linked in and Pinterest, stumbling my posts on stumble upon and subscribing for receiving free updates directly to your inbox . Stay tuned and stay connected for more technical updates."
Previous
Next Post »

If you have any question about any post, Feel free to ask.You can simply drop a comment below post or contact via Contact Us form. Your feedback and suggestions will be highly appreciated. Also try to leave comments from your account not from the anonymous account so that i can respond to you easily..