+ 1

Code is not running in 9 and 11 line , Error | I couldn't understand plz help

#include <iostream> using namespace std; int main() { int a , b ; int total marks ; cin >> a ; cin >> b ; cin >> total marks = a+b ; cout << "a is \n" << a << "\n b is \n" << b << total marks = a+b << endl ; if ( a+b>= 150) { cout << "Passed" ; if (a+b==200) { cout << "Badass" ; } } else { cout << "Better luck next time" ; } return 0; }

14th Nov 2022, 10:39 AM
Keshav Karn
Keshav Karn - avatar
7 Answers
+ 2
1) cin >> total_marks; // remove =a+b 2) Either use before as total_marks = a+b ; Or sorround by braces in cout like cout << "a is \n" << a << "\n b is \n" << b << (total_marks = a+b) ; edit : Keshav Karn if you are taking input into total_marks then actually why to assign sum of a, b to total_marks... just use without any assigent statement. cout << "a is \n" << a << "\n b is \n" << b << "\n" << total_marks;
14th Nov 2022, 10:55 AM
Jayakrishna šŸ‡®šŸ‡³
+ 2
Thank you sir for helping | Keep helping me in future also plz
14th Nov 2022, 11:05 AM
Keshav Karn
Keshav Karn - avatar
+ 1
int total marks ; invalid ,variables don't includes space or any special characters. Use _ underscore instead. cin >> total marks = a+b; invalid statement, what are you trying by this? Taking input or assigning sum of a, b? Hope it helps..
14th Nov 2022, 10:43 AM
Jayakrishna šŸ‡®šŸ‡³
+ 1
Taking input sir
14th Nov 2022, 10:46 AM
Keshav Karn
Keshav Karn - avatar
+ 1
#include <iostream> using namespace std; int main() { int a , b ; int total_marks ; cin >> a ; cin >> b ; cin >> total_marks = a+b ; cout << "a is \n" << a << "\n b is \n" << b << total_marks = a+b ; if ( a+b>= 150) { cout << "Passed" ; if (a+b==200) { cout << "Badass" ; } } else { cout << "Better luck next time" ; } return 0; }
14th Nov 2022, 10:51 AM
Keshav Karn
Keshav Karn - avatar
0
Code is not running yet
14th Nov 2022, 10:52 AM
Keshav Karn
Keshav Karn - avatar
0
I will try... You're welcome..
14th Nov 2022, 11:18 AM
Jayakrishna šŸ‡®šŸ‡³