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
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
Answered by
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
Computer Science,
7 months ago
Social Sciences,
7 months ago
English,
7 months ago
Math,
1 year ago
Chemistry,
1 year ago
Social Sciences,
1 year ago
Math,
1 year ago
Science,
1 year ago