Q. The marks obtained by a student in 5 different subjects are input through the keyboard.
The student gets a division as per the following rules:
Percentage above or equal to 60- 1st division
Percentage between 50 and 59- 2nd division
Percentage between 40 and 49- 3rd division
Percentage less then 40- Fail
Write a C program to calculate the division obtained by the student.
Ans.
/*c program for read 5 subject marks and calculate percentage & division of student*/
/*we assume total marks is 500*/
#include<stdio.h>
int main()
{
float m1,m2,m3,m4,m5,avg,per; //m=marks
printf("Enter 5 subject marks: ");
scanf("%f %f %f %f %f",&m1,&m2,&m3,&m4,&m5);
per = (m1+m2+m3+m4+m5)*100/500;
printf("Student get %0.2f percentage. \n",per);
if(per>=60)
printf("1st Division");
else if(per>=50 && per<=59)
printf("2nd Division");
else if(per>=40 && per<=49)
printf("3rd Division");
else if(per<40)
printf("Fail");
return 0;
}
The output of above program would be:
Related programs:
The student gets a division as per the following rules:
Percentage above or equal to 60- 1st division
Percentage between 50 and 59- 2nd division
Percentage between 40 and 49- 3rd division
Percentage less then 40- Fail
Write a C program to calculate the division obtained by the student.
Ans.
/*c program for read 5 subject marks and calculate percentage & division of student*/
/*we assume total marks is 500*/
#include<stdio.h>
int main()
{
float m1,m2,m3,m4,m5,avg,per; //m=marks
printf("Enter 5 subject marks: ");
scanf("%f %f %f %f %f",&m1,&m2,&m3,&m4,&m5);
per = (m1+m2+m3+m4+m5)*100/500;
printf("Student get %0.2f percentage. \n",per);
if(per>=60)
printf("1st Division");
else if(per>=50 && per<=59)
printf("2nd Division");
else if(per>=40 && per<=49)
printf("3rd Division");
else if(per<40)
printf("Fail");
return 0;
}
The output of above program would be:
Figure: Screen shot for read student marks and calculate percentage and find division C program |
Related programs:
Why are you using return 0 instead of getch() ???......What is the difference between these two??
ReplyDeleteWhen we use int main() then we write return 0;
Deletewhen we use void main() then we write getch();
Why are you using return 0 instead of getch() ???......What is the difference between these two??
ReplyDelete@Gurpreet,
DeleteIn above program we used "int main()", i.e. main() is a integer type function so its return something so we use "return 0" (it is also indicating that this is last line program and program want to close.)
In above program we not use " getch() " but we can.
In software engineering it is says that when we close application/software then, there are comes a confirmation message some like as "Are you sure you want to exit", we say "yes" and exit.
For using "getch()" C compiler require 2 enter for exit(one is display and second is exit) so there are not use getch().
grewal ......return 0 means " it is a return type means while u using int like datatypes .....u hve to put return 0"
ReplyDeletegetch() it is use when u use headerfile conio.h ..........otherwise.......dont use that getch().......
If student enter marks more then 100 then there is no condition for that. how can we make condition in it
ReplyDeleteUse this before per=(m1+m2+m3+m4+m5)/5;
Deleteif((a<=100)&&(b<=100)&&(c<=100)&&(d<=100)&&(e<=100))
{
.....;
.....;
.....;
}
Can u do this with switch case and use the percentage by taking marks/total marks method??
ReplyDeleteWrite a pragram that inputs marks os ten students and prints the list of marks that are above average
ReplyDeleteHow to do it with arrays?
ReplyDeletehelp me out with this please Write a C program that prompts for students’ final grades in 5 units in a given class (the grades are integer values in the range 0-100). The program then displays the class grade average, the highest grade, and how many students in the class failed the course (a grade less than 40 is a failing grade). If a student fails in more than 2 subjects then a message “DISCONTINUATION” is displayed at the very end. An example running session looks as follow
ReplyDeletethanks
ReplyDelete0111010000111011011100000111001001101101011100000111010000101000010111000010011000100011001100000011001100111001001110110110100001100001011000110110101101100101011001000101110000100110001000110011000000110011001110010011101100101001001001100110110001110100001110110010111101110011011000110111001001101001011100000111010000100110011001110111010000111011
ReplyDeleteif student gets less than 20 marks ( ie failed in one subject than ) what ?? this prgrm jst add all subject marks and shows its division !!
ReplyDeletehow to do with arrays...
ReplyDeleteplease answer with the code
i need total marks ,average, and percentage of student based on no. of subjects by user .
ReplyDeletehelp !!
how to exactly write this program using switch case
ReplyDeleteHow to exactly write this program using switch case
ReplyDeleteundeclared per
ReplyDeletehahaha.. check it.... he didn't create per variable,,. how can u use that variable with out declaring the variable.. am i correct...
The variable 'per' had been declared as float.
Delete