Computer Science, asked by ashishtheboss9075, 10 months ago

1.) The following program is supposed to print the following pattern. Some part of the program is replaced by _n__ where n is 1 to 5, fill this part so that program works correctly.
5
45
345
2345
12345
class ques
{
public static void main(String args[])
{
for(__1__; __2__; i–)
{
for(__3__; __4__; __5__)
System.out.print(j);
System.out.println();
}
}
}

Answers

Answered by sanchari46
0

Holla Mate ur answer is...

for(i=5;i>=1;i--)

{

for(j=i;j<=5;j++)

and the rest is written...

Hope it helps ❤❤❤❤


rishitgrg: Kitna baaki hai
sanchari46: Hold up 30 mins bad baat kare
sanchari46: please tab tak pard lo
sanchari46: please please
rishitgrg: Ok
rishitgrg: Sorry for if I disturb u
sanchari46: No no u are not disturbing
rishitgrg: Ok
rishitgrg: How much installed
sanchari46: Are abhi tak 50℅ bhi nahi huwa
Answered by Anonymous
0

Following are the parts that need to be replaced in the program

__1__  to  i=5

__2__  to  i>0

__3__  to  j=i

__4__  to  j<=i

__5__  to  j++

Nested looping is being performed here to print the required pattern. Loop of ‘i’ is the outer loop and the loop of ‘j’ is the inner loop.

Hence, after replacing the required parts, the final code will look like:-

class ques

{

public static void main(String args[])

{

for(i=5;i>=1;i--)

{

for(j=i;j<=5;j++)

{

System.out.print(j);

System.out.println();

}

}

}  

Similar questions