Program to print 1
1 2
1 2 3
1 2 3 4 like that
Answer Posted / aditya
public class pattern
{
public static void main(int n)
{
int i,j,k;
for(i=1;i<=n;i++)
{
for(j=n;j>i;j--)
{
System.out.print(" ");
}
for(k=1;k<=i;k++)
{
System.out.print(+k+" ");
}
System.out.println();
}
}
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
we have syntax like for(int var : arrayName) this syntax is to find whether a number is in the array or not.but i want to know how to find that number's location.
When throw keyword is used?
What is a ternary operator in java? What is an interface?
How do you convert an int to a string in java?
What is the independent variable in an experiment?
Explain illegalmonitorstateexception and when it will be thrown?
How many types of exception can occur in a java program?
Which is easier .net or java?
What is a stringbuffer?
What is formatted output in java?
What is an error in java?
What is object cloning in Java?
Is hashmap thread safe?
Are floats faster than doubles?
Write a program to print count of empty strings in java 8?