Hourglass pattern printing in cpp

# Hourglass Pattern in C++

// C++ Code for pattern Printing

#include <iostream>using namespace std;

 

// Function to demonstrate printing pattern

void pypart(int n)

{

int i = 1, j = 0;

while (i <= n) {

while (j <= i – 1) {

cout << i << ” “;

j++;

}

j = 0;

i++;

cout << endl;

}

}

 

// Driver Code

int main()

{

int n = 5;

 

// Function Call

pypart(n);

return 0;

}

Leave a Reply

Your email address will not be published. Required fields are marked *