logo codesdope
Level 1
1.
Write a program to print
*
**
***
****
on screen.
Answer
class Ans{
  public static void main(String[] args){
    System.out.println("*\n**\n***\n****");
  }
}
									

2.
Print the following pattern on the screen
*****
 *** 
  *  
 *** 
*****
Answer
class Ans{
  public static void main(String[] args){
    System.out.println("*****\n *** \n  *  \n *** \n*****");
  }
}
									

3.
Write a program to print the sum of the numbers 2, 4 and 5.
Answer
class Ans{
  public static void main(String[] args){
    System.out.println(2+4+5);
  }
}
									

4.
Write a program to print the difference and product of the numbers 45 and 32.
Answer
class Ans{
  public static void main(String[] args){
    System.out.println(45-32);
    System.out.println(45*32);
  }
}
									

5.
Write a program to get the following output.
Hey there,
I am data!
Answer
class Ans{
  public static void main(String[] args){
    System.out.println("Hey there,\nI am data!");
  }
}
									
Doubt? Ask question
Close

Welcome.please sign up.

Close

Welcome.please login.