Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int resp=1;
- int x = 5;
- int* y = &x;
- int sqr = x * (*y);
- cout << "Square of 5 is = " << sqr << endl;
- while (resp !=0)
- {
- cout << "Do you want to find the square of another number? (1 - yes ; 0 - no)" << endl;
- cin >> resp;
- if (resp !=0 && resp !=1)
- {
- cout << "Unknown response! " << endl;
- break;
- }
- else if (resp == 0)
- {
- cout << "Okay then." << endl;
- break;
- }
- else if (resp == 1)
- {
- cout << "What is your number? " << endl;
- cin >> *y;
- cout << "Square of " << x << " is = " << *y * (*y) << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement