C++ プログラミング クラスのスイッチ選択メニューに取り組んでいます。メニューを機能させることができましたが、作成したメニューの終了選択でプログラムを停止する方法がわかりません。
私のコードは
#include <iostream>
using namespace std;
int main()
{
char selection;
do
{
cout << " IHCC Computer Science Registration Menu\n";
cout << " ====================================\n";
cout << " 1. Welcome to Computer Programming In C++\n";
cout << " 2. Welcome to Java Programming\n";
cout << " 3. Welcome to Android Programming\n";
cout << " 4. Welcome to iOS Programming\n";
cout << "\n";
cout << " 5. Exit\n";
cout << " ====================================\n";
cout << " Enter your selection: ";
cin >> selection;
cout << endl;
switch (selection)
{
case '1':
cout << "Computer Programming In C++\n";
cout << "\n";
break;
case '2':
cout << "Java Programming\n";
cout << "\n";
break;
case '3':
cout << "Android Programming\n" ;
cout << "\n";
break;
case '4':
cout << "iOS Programming\n";
cout << "\n";
break;
case '5':
cout << "Goodbye.\n";
break;
default: cout <<selection << "is not a valid menu item.\n";
cout << endl;
}
}while (selection != 0 );
return 0;
}