Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ switch case break

#include <iostream>
using namespace std;

int main(){
    int number;
    cout<<"Enter an integer: ";
    cin>>number;

    switch (number){        //switch statement
        case 1:
            cout<<"NUMBER IS 1"<<endl;
            break;
        case 2:
            cout<<"NUMBER IS 2"<<endl;
            break;
        case 3:
            cout<<"NUMBER IS 3"<<endl;
            break;
        case 4:
            cout<<"NUMBER IS 4"<<endl;
        case 5:
            cout<<"NUMBER IS 4 OR 5"<<endl;
            break;
        default:
            cout<<"NUMBER IS NOT FROM 1 TO 5"<<endl;
            break;
    }
    cout<<endl;
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: chrono start time in c++ 
Cpp :: c++ check if char is number 
Cpp :: multiline comment in c++ 
Cpp :: how to make a random number in c++ 
Cpp :: initialize whole array to 0 c++ 
Cpp :: cpp unions 
Cpp :: c++ printf char as hex 
Cpp :: convert all characters in string to uppercase c++ 
Cpp :: struct and array in c++ 
Cpp :: c++ std::sort 
Cpp :: max of a vector c++ 
Cpp :: footnote appears in the middle latex 
Cpp :: c++ random number within range 
Cpp :: cpp init multidimensional vector 
Cpp :: include cpp 
Cpp :: udo apt install dotnet-sdk-5 
Cpp :: c++ for else 
Cpp :: c++ cast char to string 
Cpp :: c++ default parameters 
Cpp :: C++ structure (Struct) 
Cpp :: naive pattern matching algorithm 
Cpp :: 2d array c++ 
Cpp :: could not find the task c c++ active file 
Cpp :: case label in c++ 
Cpp :: change colour of output to terminal c++ 
Cpp :: how to square a number in c++ 
Cpp :: cpp return array 
Cpp :: string length in c++ 
Cpp :: new line in c++ 
Cpp :: Max element in an array with the index in c++ 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =