Tell me the programme for this
@
1 2
@ @ @
1 2 3 4
Answers were Sorted based on User's Feedback
public class PrintTriangle {
public static void main(String[] args) {
int n=4;
for(int i=1;i<=n;i++) {
for(int j=0;j<2*n-i;j++) {
System.out.print(" ");
}
for(int j=1;j<=i;j++) {
if(i%2 != 0) {
System.out.print("@"+" ");
} else {
System.out.print(j+" ");
}
}
System.out.println();
}
}
}
Is This Answer Correct ? | 7 Yes | 0 No |
Answer / varun
public class HelloWorld{
public static void main(String []args){
int k=1;
for(int i=0;i<4;i++)
{
for(int j=0;j<=i;j++)
{
if(i%2==0)
System.out.print("@");
else
System.out.print(++k);
}
System.out.println();
k=0;
}
}
}
Is This Answer Correct ? | 2 Yes | 0 No |
public class PrintTriangle {
public static void main(String[] args) {
int n=4;
for(int i=1;i<=n;i++) {
for(int j=0;j<2*n-i;j++) {
System.out.print(" ");
}
for(int j=1;j<=i;j++) {
if(i%2 != 0) {
System.out.print("@"+" ");
} else {
System.out.print(j+" ");
}
}
System.out.println();
}
}
}
Is This Answer Correct ? | 1 Yes | 0 No |
public class TriangleDisplay {
public static void main(String[] args) {
int n = 4;
for (int i = 1; i <= n; i++) {
for (int j = 4; j < 2 * n - i; j++) {
System.out.print(" ");
}
for (int j = 1; j <= i; j++) {
if (i % 2 != 0) {
System.out.print("@" + " ");
} else {
System.out.print(j + " ");
}
}
System.out.println();
}
}
}
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / sachin
package abc;
public class Sachin {
int n=4;
public static void main(String... args){
Sachin s=new Sachin();
for (int i=0;i<s.n;i++){
if(i%2==0){
for(int a=0; a<i+1;a++){
System.out.print("@");
}
}else{
for(int a=0; a<i+1;a++){
System.out.print(a+1);
}
}
System.out.println();
}
}
}
Is This Answer Correct ? | 0 Yes | 0 No |
what is meaning of JIT?
we cannot create an object of interface but we can create a variable of it
do I need to use synchronized on setvalue(int)? : Java thread
Can you have an inner class inside a method and what variables can you access?
Explain the difference between map and flatmap stream operation?
what is the difference between AWT and SWING what is the advantage of using swing?
Which arithmetic operations can result in the throwing of an arithmeticexception?
What is Distributed Application and what is its usage?
What is design pattern and there types?
Explain constructors and types of constructors in java.
How do you clear a method in java?
What are the legal operands of the instanceof operator?