whats wrong with this code

#include<conio.h>
#include<iostream.h>
main()
{
clrscr();
char name[20], selection;
float q1,q2,qav,att,me,av;
cout<<"My Grading Sheet";
cout<<"\nEnter name: ";
cin>>name;
cout<<"\nEnter quiz 1: ";
cin>>q1;
cout<<"\nEnter quiz 2: ";
cin>>q2;
qav=(q1+q2) /2;
cout<<" \n The quiz average is: "<<qav;
cout<<"\nEnter attendance: ";
cin>>att;
cout<<"\nEnter Major Exam ";
cin>>me;
av=(qav+att+me)/3;
cout<<"\n Your grade "<<name<<" is "<<av;
cout<<"\n Have a nice day "<<name;
if (av>=75)
{
cout<<"\nYou passed!";
}
else
{
cout<<"\nYou failed!";
}
cout<<"\nYour rank "<<name<<" is "<<selection;

switch(selection)
{
case (100):
cout<<"A"<<endl;
break;
case (99):
cout<<"A"<<endl;
break;
case (98):
cout<<"A"<<endl;
break;
case (97):
cout<<"A"<<endl;
break;
case (96):
cout<<"A"<<endl;
break;
case (95):
cout<<"A"<<endl;
break;
}
getch();
}


Using swith structure

average of:
100-95 RANK "A"
94-90 RANK "B"
89-85 RANK "C"
84-80 RANK "D"
79-75 RANK "E"
74 and below RANK "F"

kindly need your help. Thanks!
1) it is not inside a code box

2) main() should be void main()

3) function clrscr(); in not defined. Try void clrscr() {system("cls");}
closed account (z05DSL3A)
ynnejneib,

It may help if you tell us what the problem is that you are having. It looks like you are using 'old' c++, which is fine if you are also using an old compiler, but you may be given wrong advice.




Last edited on
For one, selection is never initialized.
Topic archived. No new replies allowed.