Advertisement
Asif_Anwar

Problem-3

Mar 17th, 2021
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int main()
  5. {
  6.     int cnt = 0;
  7.     int size;
  8.     while(true) {
  9.         cout << "Enter a size or a negative number to stop: ";
  10.         cin >> size;
  11.         if(size<0) {
  12.             cout << "A total of " << cnt << " *s were printed.\n";
  13.             break;
  14.         }
  15.         cnt += size*size;
  16.         for(int i=0; i<size; i++) {
  17.             for(int j=0; j<size; j++) {
  18.                 cout << "*";
  19.             }
  20.             cout << "\n";
  21.         }
  22.     }
  23.     return 0;
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement