Wap in cpp to print following pattern using for loop
1
11
111
1111
11111
#include<iostream.h>
#include<conio.h>
void main()
{ int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i; j++)
{ cout<<”1”; }
}
getch();
}
1
11
111
1111
11111
#include<iostream.h>
#include<conio.h>
void main()
{ int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i; j++)
{ cout<<”1”; }
}
getch();
}
lol!
ReplyDeletegud and helpful
ReplyDeletewhy would we use j loop in this case
ReplyDeleteits not j loop its for loop
Deletej is just variable
j is variable
ReplyDeletefor loop is used because it allow control to be in our hand
j loop gives us the column and i gives the row of the pattern..
ReplyDelete