Get Email Subscription

Enter your email address:

Delivered by FeedBurner

Monday, January 4, 2010

Write a program in 'C' to calculate marks and to find and assign the class (First, Second, Third, Fail) depending upon the percentage.(Using if else)

Write a program in 'C' to input the marks out of 100 obtained by a student in seven subject and to find and assign the class depending upon the percentage as follows:-
if % 60 or above 60 than first class
if % between 50 and less than 60 than second class
if % between 40 and less than 50 than third class
if % below 40 then fail



#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int m1, m2, m3, m4, m5, m6, m7, sum;
float per;
printf("Enter the marks in 7 subjects \n");
scanf("%d %d %d %d %d %d %d",&m1,&m2,&m3,&m4,&m5,&m6,&m7);
sum = m1 + m2 + m3 + m4 + m5 + m6 + m7;
per = sum / 7;
if(per >= 60)
printf("Per = %f First Class \n", per);
else
if(per >= 50)
printf("Per = %f Second Class \n", per);
else
if(per >= 40)
printf("Per = %f Third Class \n", per);
else
printf("Per = %f Fail \n", per);
return(0);
}


For eg :-

Output :-
Enter the marks in 7 subjects
10 20 30 40 50 60 70
Per = 40.000000 Third Class

Related Posts by Categories



0 comments:

About This Blog

Lorem Ipsum

  © Blogger templates Newspaper III by Ourblogtemplates.com 2008

Back to TOP