Created
May 21, 2018 09:25
-
-
Save aldhinya/f0566abc4253db05870aad516e04e769 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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