Computer Science, asked by yogeshkumar30451, 11 months ago

Write a program to print the following output using for loops. 1 22 333 4444

Answers

Answered by fuzailshaikh92
0

Answer:

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();

}

Explanation:

//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

Attachments:
Answered by shilpa85475
2

Code is given below to print 1 22 333 4444

EXPLANATION:  

This can be done through nested loops. The second loop j will work up to the first loop I and then it will print 1 one time, 2 two times, 3 three times and so on.

public static void printingnumbers() {

   for (int line = 1; line <= 5; line++)

                                          {

   for (int j = 1; j <= line; j++) {

   System.out.print(line);

                       }

   System.out.println();

               }

       }

Similar questions