Friday, June 18, 2021

program in Java to display the natural numbers using do while loop (Java) (188)

package com.company;
import java.util.Scanner;
public class Program25 {
public static void main(String[] args) {
Scanner put = new Scanner(System.in);
System.out.println("please enter the number of terms:");
int n=put.nextInt();
int i=1;
do {
System.out.println("enter a number:");
int num=put.nextInt();
i++;
}while(i<=n);
}
}

No comments:

Post a Comment