Advertisement
Michaelrenard01

2/21 class

Feb 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main() {
  4.     int n = 0;
  5.     int s = 0;
  6.     //std::cout << "**" << std::endl;
  7.  
  8.  
  9.     std::cout << "Enter a number: " << std::endl;
  10.     std::cin >> n;
  11.  
  12.     while (n < 0 || n > 30 || std::cin.fail()) {
  13.         if (std::cin.fail()) {
  14.             std::cin.clear();
  15.             std::cin.ignore(100, '\n');
  16.         }
  17.         std::cout << "Enter a number: " << std::endl;
  18.         std::cin >> n;
  19.  
  20.     }
  21.     for (int i = 0; i <= n; i++) {
  22.         for (int j = 0; j < i; j++) {
  23.             std::cout << "*";
  24.         }
  25.  
  26.     std::cout << std::endl;
  27. }
  28.  
  29.         return 0;
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement