0
Trying switch case statement need help making it work
#include <iostream> #include <string> using namespace std; int main() { char stand; char F, J, S; cin >> stand; switch (stand) { case F: cout << "first year"; break; case S: cout << "sohmore senior"; break; case J: cout << "junior"; break; default: } return 0; }
3 Answers
+ 5
#include<iostream>
#include<string>
using namespace std;
int main()
{
char stand;
cin >> stand;
switch (stand) {
case 'F':
cout << "first year";
break;
case 'S':
cout << "sohmore senior";
break;
case 'J':
cout << "junior";
break;
default:
cout<<"default";
}
return 0;
}
+ 3
Always put a character in single quotes while writing in switch case.
And also use a default statement if you are declaring a default case or either don't declare any default case. Default statement is not compulsory.
0
thathank you sir wow