Switch..Case C++ example

This is how the switch..case in c++ work :
#include <iostream.h>
#include <conio.h>
void main(){
    int nilai;
   cout<<"Masukkan Nilai : ";
   cin>>nilai;
   switch(nilai){
       case 0:
          cout<<"Super Parah"<<endl;break;
      case 1:
          cout<<"Sangat Parah"<<endl;break;
      case 2:
          cout<<"Parah"<<endl;break;
      case 3:
          cout<<"Hampir Parah"<<endl;break;


      case 4:
          cout<<"Sangat Kurang"<<endl;break;
      case 5:
          cout<<"Kurang"<<endl;break;
      case 6:
          cout<<"Cukup"<<endl;break;
      case 7:
          cout<<"Lebih dari Cukup"<<endl;break;
      case 8:
          cout<<"Baik"<<endl;break;
      case 9:
          cout<<"Sangat Baik"<<endl;break;
      case 10:
          cout<<"ISTIMEWA"<<endl;break;
         default :
             cout<<"Input Data Salah !";
         }
         getch();
     }
Previous
Next Post »