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 } ^
4 odpowiedzi
+ 6
add ; after int main() and add ; after ...default case"
+ 6
my mistake. dont add ; after main().
place bracket sign "{" after main().
if there is space between main and (), delete it.
+ 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
+ 1
add break; at end of default section