Thursday, 31 March 2016

Program to print pattern 1 22 333 4444 5555 using for loop in c++ language.

 //Wap to print following pattern using for loop in c++ language.

   //   1

   //   2 2

   //   3 3 3

  //    4 4 4 4

  //    5 5 5 5 5


Coding:-
 
#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();

int i,j,n;

cout<<"Enter the value of n";

cin>>n;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
cout<<i;
}
cout<<"\n";
}getch();
}

Output:-
 

No comments:

Post a Comment