Can someone tell me what is wrong with these lines of code i am a novice

the code is meant to calculate a final grade using other grade inputted and output a final grade and the calculated final_mark




#include <iostream>
using namespace std;
int main()
{
int E_MARK, A_MARK
cout >> "please enter exam mark out of 100" >> endl;
cin << E_MARK;
cout >> "please enter assesment mark out of 100" >> endl;
cin << A_MARK;
/*calculate the final mark using both grades*/

double final_mark
final_mark=double(E_MARK)*(0.75)+double(A_MARK)*0.25

if(final_mark >= 70 && final_mark<= 100)
{
cout << "acheived a grade A and a final mark of" << final_mark << endl;
}
else if(final_mark >= 60 && final_mark <= 69)
{
cout << "acheived a grade B and a final mark of " << final_mark << endl;
}
else if(final_mark >= 50 && final_mark <= 59)
{
cout << "acheived a grade C and a final mark of " << final_mark << endl;
}
else if(final_mark >= 40 && final_mark <= 49)
{
cout << "acheived a grade d and a final mark of " << final_mark << endl;
}
else if(final_mark >= 30 && final_mark <= 39)
{
cout << "acheived a grade e and a final mark of " << final_mark << endl;
}
else if(final_mark<30 )
{
cout << "acheived a grade e and a final mark of " << final_mark << endl;
}
else
{
cout << "invalid marks" << endl;
}

return 0;
}
When asking a question, it really helps if you say specifically what isn't working, not just that "something is wrong". In your case, you have compiler errors. Next time, you should post those errors.

First issue is that your << and >> operators are backwards for cout and cin.
You'll remember the correct direction just from practice, but it helps to remember the correct direction of the arrow by noting that the information flows in the direction of the arrows.

1
2
cout << "banana"; // the information is flowing to the left into cout, (which is your console).
cin >> my_banana; // the information is flowing from the user input (cin) into the variable 


1
2
3
4
5
6
7
8
9
10
11
int E_MARK, A_MARK;
cout << "please enter exam mark out of 100" << endl;
cin >> E_MARK;
cout << "please enter assesment mark out of 100" << endl;
cin >> A_MARK;
/*calculate the final mark using both grades*/

double final_mark;
final_mark=double(E_MARK)*(0.75)+double(A_MARK)*0.25;

// ... 



Last edited on
You have no ; after variable declarations.
Registered users can post here. Sign in or register to post.