0

what is wrong in this code?? c++ super beginners

#include <iostream> using namespace std; int main () { int age = 25; switch (age) { case 16: cout << "Too young"; break; case 42: cout << "Adult"; break; case 70: cout << "Senior"; break; default: cout << "This is the default case" } return 0; } as this are the errors the output finds: ..\Playground\: In function 'int main()': ..\Playground\:18:5: error: expected ';' before '}' token } ^

19th Feb 2017, 4:41 PM
Kira Anleu Estrada
Kira Anleu Estrada - avatar
4 odpowiedzi
+ 6
add ; after int main() and add ; after ...default case"
19th Feb 2017, 4:47 PM
Agus Mei
Agus Mei - avatar
+ 6
my mistake. dont add ; after main(). place bracket sign "{" after main(). if there is space between main and (), delete it.
19th Feb 2017, 4:53 PM
Agus Mei
Agus Mei - avatar
+ 2
Just add a semicolon in the cout statement of default case. You do not need to add break statement in switch case int the last case i.e. default
20th Feb 2017, 6:18 AM
Megatron
Megatron - avatar
+ 1
add break; at end of default section
19th Feb 2017, 5:57 PM
ahmed khattab
ahmed khattab - avatar