Thursday, January 24, 2013

C Language Example # 11 Result Generator using IF... else statement including prediction of Class

C Language Example # 11 Result Generator using IF... else statement including prediction of Class.

Lets improve result generator program to include class using if ... else statement..


C Language Code:

//Written by Latest Technology Guide    
//Title : Example 11 : Result Generator using IF... else statement including prediction of Class  .
  
#include <stdio.h>
#include <conio.h>



void main()
{
clrscr();
float m1,m2,m3,m4,m5,m6,m7,result,total,percentage;

printf("Enter Marks of All Subject (7 Subject) : \n");
scanf("%f %f %f %f %f %f %f",&m1,&m2,&m3,&m4,&m5,&m6,&m7);

total=m1+m2+m3+m4+m5+m6+m7;
percentage=total/7.0;

if(m1>=36 && m2>=36 && m3>=36 && m4>=36 && m5>=36 && m6>=36 && m7>=36)
{
printf("\nTotal   \t : %.2f",total);
printf("\nResult\t\t : Pass");
printf("\nPercentage \t : %.2f",percentage);

if(percentage>=70)
printf("\nGrade is         : A");
else
{
if(percentage>=60)
printf("\nGrade is         : B");
else
{
if(percentage>=50)
printf("\nGrade is         : C");
else
printf("\nGrade is         : Pass");
}
}
}
else
printf("\nResult\t : Fail");

getch();
}

Output:

We think there is no need of Output for this program.


--------------------------------------------------------------------------------
Explanation of C Language Example  # 11 Result Generator using IF... else statement including prediction of Class.

* We have assume that subjects are 7 as per our previous program..
* Want to check out our previous program that was simple result generator ( Click Here )* Passing Mark is 36. Means if student secures 36 or more marks then he/she will be passed in the subject.
* If student is passed then we are calculating total marks, result and percentage.
* Here we will also calculate the grade based on following criteria.
* If student secures more than 70 percentage Grade will be A
* if student secures percentage between 60 to 69 Grade will be B.
* if student secures percentage between 50 to 59 Grade will be C.
* In all other case if student is pass then Grade is Pass

Still having doubts you can post comment, will explain in details.

Note: All programs are developed and tested using Turbo C++ 3.0 under Windows XP. We just want to provide guidelines to the users. If you are using any other Compiler or other operating system they you need to modify this program as per your requirements. 

1 comment: