Write a program to accept a number and to print numbers in
pyramid format?
for eg:for a no. 5
1
212
32123
4321234
543212345

Answer Posted / pravin pawar

public static void main(String args[])
{
for(int r=1;r<=5;r++)
{
for(int s=5-r;s>0;s--)

System.out.print(" ");

for(int c=r;c>=1;c--)
System.out.print(c);

for(int c=2;c<=r;c++)

System.out.print(c);

System.out.print("\n");
}
}

Is This Answer Correct ?    8 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is different between oops and c++

2004


What is encapsulation example?

549


Can destructor be overloaded?

599


How is class defined?

588


What is the oops and benefits of oops programming?

555






What is encapsulation in oops?

538


Can abstract class have normal methods?

615


What are the important components of cohesion?

557


Where You Can Use Interface in your Project

1427


What is pointer in oop?

539


Can we have inheritance without polymorphism?

617


What is encapsulation process?

582


what's the basic's in dot net

1740


What are classes oop?

598


What is a superclass in oop?

671