Advertisement
BojidarDosev

Untitled

Mar 21st, 2024
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int resp=1;
  7.  
  8. int x = 5;
  9. int* y = &x;
  10.  
  11. int sqr = x * (*y);
  12.  
  13. cout << "Square of 5 is = " << sqr << endl;
  14.  
  15. while (resp !=0)
  16. {
  17. cout << "Do you want to find the square of another number? (1 - yes ; 0 - no)" << endl;
  18. cin >> resp;
  19.  
  20. if (resp !=0 && resp !=1)
  21. {
  22. cout << "Unknown response! " << endl;
  23. break;
  24. }
  25. else if (resp == 0)
  26. {
  27. cout << "Okay then." << endl;
  28. break;
  29. }
  30. else if (resp == 1)
  31. {
  32. cout << "What is your number? " << endl;
  33. cin >> *y;
  34. cout << "Square of " << x << " is = " << *y * (*y) << endl;
  35. }
  36. }
  37.  
  38. }
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement