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 shape in c++

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n ; 	
	for(int i=1 ; i <= n ; i++){
		for(int j=i ; j < n; j++){
			printf(" ");
		}
		for(int j=1 ; j <= i*2-1 ; j++){
			printf("*");
		}
		printf("
");
		
	}
	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 :: vector int initialize with increasing numbers 
Cpp :: Road sign detection and recognition by OpenCV in c 
Cpp :: c++ anti debugging 
Cpp :: Corong_ExerciseNo3 
Cpp :: variable modulus 5 meaning in c++ 
Cpp :: c++ copy vector 
Cpp :: adding two dates using necessary member function in c++ 
Cpp :: Access Elements in C++ Array 
Cpp :: c++ execute thread and forget 
Cpp :: selection sort algorithm in cpp 
Cpp :: how to find common divisors of two numbers in cpp 
Cpp :: 10^18 data type in c++ 
Cpp :: Shuffle String leetcode solution in cpp 
Cpp :: private access specifier in c++ program 
Cpp :: Password codechef solution in c++ 
Cpp :: .txt file into .cpp 
Cpp :: c++ click event 
Cpp :: 1822. Sign of the Product of an Array leetcode 
Cpp :: rgb(100,100,100,0.5) validation c++ 
Cpp :: servicenow cart api 
Cpp :: for llop in c++ 
Cpp :: C++ Creating a Class Template Object 
Cpp :: fast scan in c++ 
Cpp :: To toggle (flip the status of) the k-th item of the set 
Cpp :: Pawri Meme codechef solution in c++ 
Cpp :: c++ How can I make a std::vector of function pointers 
Cpp :: catalan numbers c++ 
Cpp :: niet full form 
Cpp :: 10011101 
Cpp :: windows install cppcheck 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =