Switch case in C++
#include<iostream>
using namespace std;
int main()
{
int rollno;
char name;
int Class;
int ch;
cout<<"enter your choice : ";
cin>>ch;
switch (ch){
case 1:
cout<<"enter your name :";
cin>>name;
break;
case 2:
cout<<"enter your rollno: ";
cin>>rollno;
break;
case 3:
cout<<" enter your class : ";
cin>>Class;
break;
default:
cout<<"\n Invalid choice:";
}
return 0;
}
Output:
enter your choice : 1
enter your name :ssss
Comments
Post a Comment