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 this pointer in oop?
What is object-oriented programming? Webopedia definition
What is abstraction in oops?
What are the types of abstraction?
What is for loop and its syntax?
State what is encapsulation and friend function?
What is oops?what is its use in software engineering?
what are the different types of qualifier in java?
What is object in oops?
What is the difference between encapsulation and polymorphism?
when to use 'mutable' keyword and when to use 'const cast' in c++
What language is oop?
what is the drawback of classical methods in oops?
What is the main feature of oop?
What are constructors in oop?