0

what am i missing?

{ int x; {cin << x << endl;} if(x<10) {cout << idiot << endl;} else(x>10) {cout << smart! << endl;} }

17th Jan 2017, 2:15 AM
jonathin
3 Answers
+ 8
// Few of your syntax are wrongly allocated. // Please refer to the code below. #include <iostream> using namespace std; int main() { int x; cout << "Please input an integer" << endl; cin >> x; if (x < 10) { cout << "Baka!" << endl; } else { cout << "Sugoii!" << endl; } return 0; }
17th Jan 2017, 2:19 AM
Hatsy Rei
Hatsy Rei - avatar
+ 4
cin use >> dont endl on cin. use quotes with strings and cout. cout << "strings need quotes" you dont need braces on cin line
17th Jan 2017, 2:18 AM
jay
jay - avatar
+ 2
cin << x << endl; doesnt need to be between {} and dont need to put endl after cin and for cin is >> u can try int x; cin >> x; if (x < 10) { cout << "idiot" << endl; //quotes cause idiot isnt a variable } else { //u dont have to put nothing after else just else { (code to be executed) } cout << "smart!" << endl; } so if x < 10 print idiot otherwise print smart
17th Jan 2017, 2:21 AM
Kawaii
Kawaii - avatar