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