Search
 
SCRIPT & CODE EXAMPLE
 

CPP

Programs for printing pyramid patterns in C++

#include<iostream>
using namespace std;

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j <= i; j++)
		{
			cout << "*";
		}
		cout << "
";
	}
	return 0;
}
Comment

Pyramid pattren program in C++

#include <iostream>
using namespace std;

int main() {
  int size = 5;
  for (int i = 0; i < size; i++) {
    // print spaces
    for (int j = 0; j < size - i - 1; j++) {
      cout << " ";
    }
    // print stars
    for (int k = 0; k < 2 * i + 1; k++) {
      cout << "*";
    }
    cout << "
";
  }
  return 0;
}

/* Output
    *
   ***
  *****
 *******
*********

*/
Comment

the pyramid in c++

#include <iostream>
using namespace std;

int main()
{
    int rows;

    cout << "Enter number of rows: ";
    cin >> rows;
	
  	int i = 1;
    while(i  <= rows)
    {
      	int j = 1
        while(j <= i)
        {
            cout << "* ";
          	j++
        }
        cout << "
";
      	i++;
    }
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ short if 
Cpp :: c++ string erase all occurrences 
Cpp :: colourful text in c++ 
Cpp :: how to cehck if list has element c++ 
Cpp :: check if key exists in map c++ 
Cpp :: input output c++ 
Cpp :: print to console c++ 
Cpp :: c++ convert binary string to decimal 
Cpp :: binary search return index c++ 
Cpp :: qt qlcdnumber change value 
Cpp :: Name one example of a “decider” program that you regularly encounter in real life. 
Cpp :: how to calculate polar coordinates in c++ 
Cpp :: check file exist cpp 
Cpp :: what are various sections of process 
Cpp :: expected number of trials to get n consecutive heads 
Cpp :: creator of C++ 
Cpp :: how to sort a string in c++ 
Cpp :: c++ srand() 
Cpp :: landscape overleaf 
Cpp :: read string from binary file in c++ 
Cpp :: input a string in c++ 
Cpp :: c++ vector element search 
Cpp :: declare dynamic array c++ 
Cpp :: tarray ue4 c++ 
Cpp :: how to get a letter from the user c++ string 
Cpp :: combination code c++ 
Cpp :: c++ merge sort 
Cpp :: allow cross origin 
Cpp :: in c++ the default value of uninitialized array elements is 
Cpp :: What should main() return in C++? 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =