Blog Introductions
In this blog contains tutorials about HTML Tutorials, Python Tutorials, CSS Tutorials, How to, PHP Tutorials, Java Tutorials, C++ Tutorials, Tutorials, Examples, Source code,Learning,
Tips and Software development services. C++ Switch Case Conditional statement | C++ tutorials Bestitworriors
C++ Switch Case Conditional statement
C++ Switch Case Conditional statement | C++ tutorials Bestitworriors - Switch is use to select one block out of many block.In switch we use case to check the condation .If certein condation is match then execute the following code.If none of case is match then execute the default block.Switch is easier to write rather the writing many if-else condations.
Some Key Points of C++ Switch
- In Switch we pass parameter to check condation
- In Switch we use case statement to check the condations
- If none of case match then swich execute default block
- Switch is easir to write and take less time then multiple if-else
- Switch case check condation if match then execute the following block
- Switch is usefull when multiple condation occure
Code
#include <iostream>
using namespace std;
int main() {
int months = 4;
switch (months) {
case 1:
cout << "January";
break;
case 2:
cout << "Feburary";
break;
case 3:
cout << "March";
break;
case 4:
cout << "April";
break;
case 5:
cout << "May";
break;
case 6:
cout << "June";
break;
case 7:
cout << "Jully";
break;
}
return 0;
}
Output
April
0 Comments