Print number Pattern in C++

Advertisements

Prev Tutorial Next Tutorial

C++ Program to Print number Pattern

In C++ language you can any number Pattern. Here i will show you how to print all number Pattern in C++ language with explanation. If you want to know about basic concept of Number pattern program just try Print Number Patter Program in C.

C++ Program to Print number Pattern

#include<iostream.h>
#include<conio.h>

void main()
{
int i,j, k=1;
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<i;j++)
{
cout<<k;
k++
}
cout<<"\n";
}
getch();
}

Output

1
23
456
78910

C++ Program to Print number Pattern

#include<iostream.h>
#include<conio.h>

void main()
{
  int i, j;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=i;j++)
        {
            cout<<i;
        }
        cout<<"\n";
    }

getch();
}

Output

1
2 2 
3 3 3
4 4 4 4
5 5 5 5 5

Example

#include<iostream.h>
#include<conio.h>

void main()
{
  int i,j,k;
  k=1;
  for(i=1;i<=5;i+=2)
  {
    for(j=5;j>=1;j--)
    {
      if(j>i)
        cout<<" ";
      else
        cout<<k++;
    }
    cout<<"\n";
  }
getch();
}

Output

      1
   2 3 4
5 6 7 8 9

Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements