aapki logic mein zara problem thi is liye result nahi aaraha tha, bas aap ko is line mein: per=om/200; ko is tarhan karna he: per=om/200 * 100;
kionke percentage to aisay hi nikalta he, (Number got / Total Number * 100)
aor else if mein >=70 ki jaga >=60 karain ta ke B grade ka message bhi aasake.
ye lijye complete code isay copy ker kain run ker ke dekhlain:
Code:
#include <iostream.h>
#include <conio.h>
#include <graphics.h>
void main()
{
float phy,ch,om,per;
char n[10], fname[10];
int gd =DETECT,gm;
initgraph(&gd,&gm, "c:\\tc\\bgi");
setfillstyle(1,3);
bar(1,260,390,260);
rectangle(1,1,550,390);
line(260,390,260,390);
cout<<"\n"<<"\t"<<"\t"<<"\t"<<" name";
cout<<"\t"<<"\t"<<"\t";
cin>> n;
cout<<"\n"<<"\n"<<"\t"<<"\t"<<"\t"<<" father name";
cout<<"\t"<<"\t";
cin >> fname;
cout<<"\n\t\t\t physics";
cout<<"\t\t";
cin>> phy;
cout<<"\n\t\t\t chemistry";
cout<<"\t\t";
cin>>ch;
om=phy+ch;
per=om/200 * 100;
if (per>=70)
{
cout<<"\n\t\t\t grade a1";
cout<<"\t\t\t";
}
else if (per>=60)
{
cout<<"\n\t\t\t grade b";
cout<< "\t\t\t";
}
else
cout <<"\n\t\t\t sorry";
cout<<"\t\t\t";
getch();
closegraph();
}
Bookmarks