Write a program to print multiples of 3 from 3 to 50
Answers
Answered by
12
Answer:
// Program to print the multiples of 3 from 3 to 50 using JAVA
import java.io.*;
import java.util*;
class Multiples{
public static void main(String args [ ]) throws Exception {
Scanner sc = new Scanner (System.in);
//Declaring the variables
int n=3;int j=1;
//Printing the multiples using a do loop
do{
if( j==1){
System.out.println("The multiples of 3 between 3 to 50 are:");
}
System.out.println(n);
n=n+3;
} while(n<=50);
}
}
Explanation: The loop will run till the test condition is satisfied and will print the multiples . When the test condition will not be fulfilled , the loop will get terminated.
Similar questions