Last active
December 11, 2015 18:38
-
-
Save sprintr/4642754 to your computer and use it in GitHub Desktop.
An example of do while
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 <cstdlib> | |
#include <iostream> | |
using namespace std; | |
// standard c++ | |
int main(int argc, char *argv[]) | |
{ | |
// even if (choice = 'N'), do will run once | |
char choice = 'Y'; | |
do { | |
int a = 0, | |
b = 0, | |
c = 0; | |
cout << "Enter a and b" << endl; | |
cin >> a >> b; | |
c = a + b; | |
cout << "a + b = " << c << endl; | |
cout << "Do you want to continue (Y/N)?" << endl; | |
cin >> choice; | |
} while(choice == 'Y'); | |
system("PAUSE"); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment