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
For eg :-
Output :-
Enter the marks in 7 subjects
10 20 30 40 50 60 70
Per = 40.000000 Third Class
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< #include< #include< 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
0 comments:
Post a Comment