c++ switch
switch(expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
}
c++ switch
switch(expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
}
how to make a switch case statement in c++
#include <iostream>
using namespace std;
int main(){
int num = 5;
switch(num + 2) {
case 1:
cout << "Case1: Value is: " << num << endl;
case 2:
cout << "Case2: Value is: " << num << endl;
case 3:
cout << "Case3: Value is: " << num << endl;
default:
cout << "Default: Value is: " << num << endl;
}
return 0;
}
c++ switch
switch(a) {
case -1:
std::cout << "a == -1" << std::endl;
break;
case 0:
std::cout << "a == 0" << std::endl;
break;
default:
std::cout << "a is something else" << std::endl;
}
switch case c++
// Transfers control to one of the several statements, depending on the
//value of a condition.
switch (variable or an integer expression) {
case constant: {
//C++ code
break;
}
case constant: {
//C++ code
break;
}
default: {
//C++ code
break;
}
}
c++ switch case
switch(expr) {
case 1:
// do something
break;
case 2:
// do something
break;
default:
// do something
}
switch in c++
switch (variable) {
case 1:
// code here
break
default:
// code here
break
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us