1. Java code:
  2. import java.util.Random;
  3. public class Main {
  4. public static void main(String[] args) {
  5. // object to call random numbers
  6. Random random = new Random();
  7. int num = 0; // to store the number
  8. do {
  9. num = random.nextInt(10);
  10. System.out.println(num * num); // printing the output
  11. } while (num != 0); // terminating condition
  12. }
  13. }