Advertisement
themrsami

C++ code to draw triangle

Feb 7th, 2023
805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | Source Code | 0 0
  1. //C++ code to draw triangle
  2. #include <iostream>
  3.  
  4. int main() {
  5.     int rows;
  6.     std::cout << "Enter the number of rows: ";
  7.     std::cin >> rows;
  8.  
  9.     for (int i = 1; i <= rows; i++) {
  10.         for (int j = 1; j <= i; j++) {
  11.             std::cout << "*";
  12.         }
  13.         std::cout << std::endl;
  14.     }
  15.  
  16.     return 0;
  17. }
  18.  
Tags: C++
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement