#include<iostream.h>
#include<conio.h>
void main()
{
float subject1,subject2,subject3,subject4,subject5,total,percentage;
char name,grade;
cout<<"Welcome User, The Following Program Will Help You Evaluate The Total \n";
cout<<",Percentage and Grade Using The Marks Obtained In 5 Subjects\n";
cout<<"Enter Your Name User :";
cin>>name;
cout<<"Enter The Marks Obtained In English(out of 100) :";
cin>>subject1;
cout<<"Enter The Marks Obtained In Chemistry(out of 100) :";
cin>>subject2;
cout<<"Enter The Marks Obtained In Physics(out of 100) :";
cin>>subject3;
cout<<"Enter The Marks Obtained In Computer Science/Infomatics(out of 100) :";
cin>>subject4;
cout<<"Enter The Marks Obtained In Mathematics/Biology(out of 100) :";
cin>>subject5;
total=subject1+subject2+subject3+subject4+subject5;
percentage=(total/500)*100;
if (percentage>90&&percentage<=100)
grade='A+';
elseif (percentage>80&&percentage<=90)
grade='A';
elseif (percentage>70&&percentage<=80)
grade='B';
elseif (percentage>60&&percentage<=70)
grade='B';
elseif (percentage>50&&percentage<=60)
grade='C+';
elseif (percentage>40&&percentage<=50)
grade='C';
elseif (percentage>32&&percentage<=40)
grade='D';
else
grade='E';
cout<<"Name:"<<name;
cout<<"Total Marks:"<<total;
cout<<"Percentage:"<<percentage;
cout<<"Grade:"<<grade;
getch();
}
The problem is that it does not take any values
So the main question is how do i fix the program
ps I have been learning C++ for 3 months so we don't have any arrays,at max we have iterations
It means the program is not compiling the cin command
and no, it is supposed to take multiple letters
it only takes the name(only the first letter) and then executes the program
i want it to take the full name,all the marks then evaluate the program
abhishekm71
we have not used the commandusingnamespace std;
as i have said i started learning this language a mere 3 months
Three choices:
1) usingnamespace std; -- This is not recommended as it is too broad.
2) Qualify every reference to cin, cout and every other name from namespace std with std::
3) using std::cout; -- Usually the best if std::cout is used multiple times. It brings only the name cout into global scope.
Note that the std::getline stores a line into a variable of type std::string. It is very good to learn to use string. However, "using C++ effectively" and "learning to program" are two different things.