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 does enum stand for?
What is abstraction in oops with example?
What is static modifier?
What are the features of oop?
What is basic concept of oop?
What do you mean by overloading?
Prepare me a program for the animation of train
What is class and example?
Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.
What are objects in oop?
How do you use inheritance in unity?
Write a c++ program to display pass and fail for three student using static member function
Can we define a class within the interface?
Why polymorphism is used in oops?
What is polymorphism what are the different types of polymorphism?