Here we discussed about the Performance of a Student using if-else-if Statement. Here the difference Conditions are evaluated from the start and when a Condition is evaluated as true, the following Statements are executed and the rest of the Statements are skipped.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float marks, percentage ;
cout<<"enter the marks scored out of 700 ";
cin>>marks;
percentage = (marks/700)*100;
if(percentage>=90 && percentage<=100)
{
cout<<"\n Grade A";
}
else if(percentage>=80 && percentage<90)
{
cout<<"\n Grade B";
}
else if(percentage>=70 && percentage<80)
{
cout<<"\n Grade C";
}
else if(percentage>100)
{
cout<<"\n The marks you have enterd are incorrect";
}
else
{
cout<<"\n Grade D";
cout<<"\n you have got Grade D which is equivlant to fail in marks system";
}
}
OUTPUT OF THIS PROGRAM GRADE BY GRADE WILL BE :
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float marks, percentage ;
cout<<"enter the marks scored out of 700 ";
cin>>marks;
percentage = (marks/700)*100;
if(percentage>=90 && percentage<=100)
{
cout<<"\n Grade A";
}
else if(percentage>=80 && percentage<90)
{
cout<<"\n Grade B";
}
else if(percentage>=70 && percentage<80)
{
cout<<"\n Grade C";
}
else if(percentage>100)
{
cout<<"\n The marks you have enterd are incorrect";
}
else
{
cout<<"\n Grade D";
cout<<"\n you have got Grade D which is equivlant to fail in marks system";
}
}
OUTPUT OF THIS PROGRAM GRADE BY GRADE WILL BE :
No comments:
Post a Comment