+ 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; }
7 Réponses
+ 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;
+ 2
Thank you sir for helping | Keep helping me in future also plz
+ 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..
+ 1
Taking input sir
+ 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;
}
0
Code is not running yet
0
I will try...
You're welcome..