Contoh Program Case Switch pada C++
#include <iostream>
using namespace std;
int main ()
{
char nilai = 'A';
switch (nilai)
{
case 'A' :
cout << "95" << endl;
break;
case 'B' :
cout << "85" << endl;
break;
case 'C' :
cout << "75" << endl;
break;
case 'D' :
cout << "65" << endl;
break;
default :
cout << "E" << endl;
}
cout << "Nilaimu adalah " << nilai << endl;
cout << "Keterangan:" << endl;
cout << "A: Sempurna" << endl;
cout << "B: Bagus" << endl;
cout << "C: Cukup" << endl;
cout << "D: Kurang" << endl;
cout << "E: Error" << endl;
cin.get();
return 0;
}
Comments
Post a Comment