Calculate Result, Total Marks & Percentage using C Programming

Input name & marks of 5 subjects by user and calculate
Result, Total Marks Obtained & Percentage Secured: Code goes like this :

/* Program to take input from user : name & marks of 5 subjects & find the result, total marks obtained & percentage secured */
#include<stdio.h>
int main()
{
char name[15];
float math,english,science,computer,eph, total,percentage;
printf("Enter your name : ");
scanf("%s",name);
printf("\n Enter the marks of math,english,science,computer,eph : ");
scanf("%f %f %f %f %f",&math, &english, &science, &computer, &eph);

if(math>32&& english>32 && science>32 && computer>32 && eph>32) //Pass marks is 32 & full marks is 100 for all subjects
    {
    total=(math+english+science+computer+eph);
    percentage=total/5;
    printf("\n Congratulations %s. You've passed",name);
    printf("\n Total marks obtained is %.2f",total);
    printf("\n Percentage secured is %.2f",percentage);
    }

else
    {
    total=(math+english+science+computer+eph);
    printf("\n Sorry! %s. You've failed ",name);
    printf("\n Total marks obtained is %.2f",total);
    }
  
return 0;
}

Output : Pass Result
---------------------------


Output : Failed Result
---------------------------















I have used Dev CPP to compile this program.
If you are using Turbo C++ IDE, then use conio.h in link section after stdio.h
and use getch(); to hold the output screen, just before the end of main function.
If you have any confusion regarding the program, please, comment below.
Happy Coding !
Thank you.
Share on Google Plus

About Nepali Xoro

Interested in Information Technology, Spreading Knowledge for Nepalease IT Students."Loves Traveling", Listen Music and Surfing web.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment