logo codesdope

Practice questions on Let's program

Level 1

1.

Write a program to print
*
**
***
****
on screen.

class Ans{
  public static void main(String[] args){
    System.out.println("*\n**\n***\n****");
  }
}

2.

Print the following pattern on the screen
*****
 *** 
  *  
 *** 
*****

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.

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.

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!

class Ans{
  public static void main(String[] args){
    System.out.println("Hey there,\nI am data!");
  }
}

Level 2

Level 3

Close

Welcome.please sign up.

Close

Welcome.please login.