Selasa, 08 Maret 2016

Contoh Penggunaan Switch Case

#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

using namespace std;
int main(int argc, char** argv) {
    int number;
    cout<<"enter a positive integer number :";
    cin>>number;
   
    switch(number){
        case 1 :
            cout<<"one";
            cout<<"-------";
            break;
        case 2 :
            cout<<"two";
            break;
        case 3 :
            cout<<"three";
            break;
        default :
            cout<<"others";
            break;
    }
    return 0;
}

Tidak ada komentar:

Posting Komentar