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
what is different between oops and c++
What is encapsulation example?
Can destructor be overloaded?
How is class defined?
What is the oops and benefits of oops programming?
What is encapsulation in oops?
Can abstract class have normal methods?
What are the important components of cohesion?
Where You Can Use Interface in your Project
What is pointer in oop?
Can we have inheritance without polymorphism?
What is encapsulation process?
what's the basic's in dot net
What are classes oop?
What is a superclass in oop?