Skip to content

Instantly share code, notes, and snippets.

@aldhinya
Created May 21, 2018 09:25
Show Gist options
  • Save aldhinya/f0566abc4253db05870aad516e04e769 to your computer and use it in GitHub Desktop.
Save aldhinya/f0566abc4253db05870aad516e04e769 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main()
{
int npm;
char nama[50];
bool bad = false;
do
{
cout << "Input npm = ";
cin >> npm;
bad = cin.fail();
if (bad)
cout << "Error message" << endl;
cin.clear();
cin.ignore(10, '\n');
}
while(bad);
cout << "Input nama = ";
cin >> nama;
cout <<endl;
cout << npm <<endl;
cout << nama;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment