

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Printing Pyramid in C++
This article yields a “pyramid-like structure” as an output using the C++ programming code. In which the pyramid height and space are being determined by traversing double for loop constructs as following;
Example
#include <iostream> using namespace std; int main() { int space, rows=6; for(int i = 1, k = 0; i <= rows; ++i, k = 0){ for(space = 1; space <= rows-i; ++space){ cout <<" "; } while(k != 2*i-1){ cout << "* "; ++k; } cout << endl; } return 0; }
Output
After compilation of the above code, the pyramid will be printed looks like as.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- Related Questions & Answers
- Printing Pyramid using Recursion in C++
- Programs for printing pyramid patterns in Python
- Java Programs for printing Pyramid Patterns. (of numbers)
- Print pyramid of tutorialspoint in PL/SQL
- Program for volume of Pyramid in C++
- Program to print pyramid pattern in C
- Print Pyramid Star Pattern in Java Program
- Printing Heart Pattern in C
- Multi-Line printing in Python
- Printing Interesting pattern in C++
- Printing Triangle Pattern in Java
- Is a book printing press different from a magazine printing press?
- Printing Different pattern Bash in C++
- Printing to the Screen in Python
- Printing Integer between Strings in Java
Advertisements