nested for loops pyramid c++

//WAP to print triangle pattern... LOGIC
int num{}, i{1};
  cin >> num;
  while (i <= num) {
    for (int space = 1; space <= (num - i); space++) {  // space
      cout << " ";
    }
    for (int value = 1; value <= (2 * i - 1); value++) {  // value
      cout << value;
    }
    cout << endl; //next row
    i++;
  }

0
0
Phoenix Logan 186120 points

                                    //C++ program to display hollow star pyramid

#include&lt;iostream&gt;
using namespace std;

int main()
{
   int rows, i, j, space;

   cout &lt;&lt; &quot;Enter number of rows: &quot;;
   cin &gt;&gt; rows;

   for(i = 1; i &lt;= rows; i++)
   {
      //for loop to put space in pyramid
      for (space = i; space &lt; rows; space++)
         cout &lt;&lt; &quot; &quot;;

      //for loop to print star
      for(j = 1; j &lt;= (2 * rows - 1); j++)
      {
         if(i == rows || j == 1 || j == 2*i - 1)
            cout &lt;&lt; &quot;*&quot;;
         else
            cout &lt;&lt; &quot; &quot;;
      }
      cout &lt;&lt; &quot;\n&quot;;
   }
   return 0;
}

0
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
Write a program which will print half pyramid pattern. use 'nested for loop' for this program. C++ nested * pyramid c++ complex pattern printing pattern programs in c++ using for loop display the following figure c ++ how to draw triangle in cpp with hash cpp star print pattren pattern program in cpp Write a C++ program, which takes &lsquo;n&rsquo; as input and print a pattern with n lines using while loops in c++ c++ program to print number pyramid cpp code to print pyramid Full Pyramid of Numbers c++ c++ pyramid star c++ half pyramid while loop half pyramid using while loop c++ c++ program print half pyramid patter on natural umbers patterns in cpp c++ print triangle of stars half pyramid in c++ pyramid of stars in c++ pyramid program in cpp Write a c++ program that takes number of rows as an input from user and then using loops printthe sequence shown in the figure below : lower left triangle pattern printing problem in c++ print the pattern c++ star pyramid in c++ c++ program to print pyramid pattern using show triangle of numbers c++ star pattern in c++ using for loop how to print a triangle c++ Write a C++ program, which takes &lsquo;n&rsquo; as input and print a pattern with n lines using while loops. For example, if user enters 6 then output of the program is shown below: * ** *** **** ***** ****** pattern printing questions c++ u triangle cpp triangular matrix pyramid cpp c++ how to print many patterns drawing pattern c++ how to print pascal triangle in c++ rotate square star pattern in c++ draw pattrerens c++ output finding questions in c++ pattern inverted pyramid c++ pyramid pattern in c++ how to make a pyramid of * in c++ Write a C++ program to display fireworks in a ring shape using asteriks (*). Loops, arrays and pointers are to be used. Note: Use cls command. c++ pascal's triangle c++ c++ reverse star pattern printing patterns c++ Full pyramid c++ Given an integer N, print the corresponding Inverted Half Pyramid pattern for N. C++ Given an integer N, print the corresponding Pyramid pattern for N. C++ star pattern program in cpp pattern printing in cpp star programme cpp get piramid output in c++ c++ shapes print pascal triangle program in cpp nested loops c++\ print triangle c++ printing shapes in c++ cpp pyramids in pattern count how to print pattern in c++ triangle pattern in cpp Program to print 4 different patterns of stars and numbers. pyramid printing cpp program count pyramid stars c++ program to print pattren n c++ pyramid using c++ C / C ++ Program to display string triangle pattern cpp pyramid.c cpp day 01 output of a for c++ pattern print star triangle in c++ printing pattern c++ c++ nested loops pyramid number pattern c++ number pattern programs in c++ using for loop drawing Inverted triangle C++ math patterns with nested for loops c++ asterisk pyramid c++ pryramid code c++ ##### pattern cpp pyramid pattern c++ how to print star 5 time in c++ pattern program c++ for loop c++ pyramid C++ printing a user inputted &quot;string&quot; in a right triangle format c++ print triangle with dots special pyramid code c++ pyramid code c++ pyramid game code in c++ program to print a triangle composed of a symbol e.g. asterisk c++ number pattern programs in cpp 20 Different Number Pattern Programs In cpp pattern using nested for loop. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * IN C++ c++ program to print a triangle of stars half pyramid letters c++ patterns program in cpp programs for printing pyramid patterns in c++ nested for loops pyramid c++ Write a function void printPattern(int n), that prints a pattern of triangles depending on the value of n print a star pattern in c++ cpp number pattern cpp pattern triangle c++ for loop pattern pyramid in cpp print triangle of stars in c++ cpp star patterns C++ Display Triangle Patterns With Nested Loops pattern printing c++ star pattern using if statements c++ star-patterns-in-c-plus-plus using if pyramid in c++ print a pyramid in cpp print pyramid in cpp for loop different patterns in CPP how to make full pyramid in c++ using string triangle pyramid c++ create array pyramid c++ c++ print pyramid print starts in c+ pyramid pattern in cpp pattern printing question in c++ pattern printing in c++ nested loop patterns c++ c++ to print pattern printing patterns in c++ c++ program that print pyramid drawing pattern using c++ pyramidal c++ algorithm full pyramid in c++ print pattern and space in cpp
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source