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 / rathod rajesh
for(int i=1;i<=5;i++)
{
for(int k=5;k>=i;k--)
{
System.out.print(" ");
}
for(int j=i;j>=1;j--)
{
System.out.print(j);
}
for(int j=2;j<=i;j++)
{
System.out.print(j);
}
System.out.println();
}
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
What are functions in oop?
What is polymorphism explain its types?
when to use 'mutable' keyword and when to use 'const cast' in c++
What is new keyword in oops?
Is enum a class?
What is the types of inheritance?
how to get the oracle certification? send me the answer
What is variable example?
Why do we use inheritance?
what is the drawback of classical methods in oops?
Why do we use polymorphism?
What is the diamond problem in inheritance?
what type of questions
can we make game by using c
write a program to enter a string like"sunil is a good boy and seeking for a job" not more than 10 characters including space in one line,rest characters should b in other line.if the next line starts from in between the previous word,then print whole word to next line.