Program to print half pyramid using * and 123 ||how to print a pattern in c++ // pyramid in pattern form with easy method //Source code


Source Code:
#include<iostream>
#nclude<conio.h>
using namespace std; 
int main()
{
for(int r=1;r<=5; r++)
{
for(int c=1;c<=r;c++)
    {   
           cout<<"*";
      }
cout<<endl;   // to terminate the row and went to next row
}
   getch();
}
Output:
*
* *
* * *
* * * *
* * * * *
OUTPUT 
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Source Code:
#include<iostream>
#nclude<conio.h>
using namespace std; 
int main()
{
for(int r=1;r<=5; r++) // this for loop is for rows
{
for(int c=1;c<=r;c++)  // this for loop is for columns
    {   
           cout<<c;
      }
cout<<endl;   // to terminate the row and went to next row
}
   getch();
}

Comments

Popular posts from this blog

How to create Simple ATM Machine in C++ Program||ATM Program deposit withdraw money in c++|Using CLI || C++ project with Source Code || MH Computer Academy(Muhammad Hashmi)

How to Calculate GPA/CGPA || GPA Calculator Step by Step in C++ ||Sourc...

C++ Project GYM Management System || Source Code with Explanation | MH Computer Academy || Muhammad Hashmi || Learn Programming