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; }

11th Oct 2016, 5:57 AM
Reginald Wright
Reginald Wright  - avatar
3 Respuestas
+ 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; }
11th Oct 2016, 11:09 AM
Celal Aybar
Celal Aybar - avatar
+ 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.
16th Oct 2016, 6:05 PM
Neha Bit
Neha Bit - avatar
0
thathank you sir wow
11th Oct 2016, 11:11 AM
Reginald Wright
Reginald Wright  - avatar