Question: The code snippet below checks whether a given number is a prime number. What will be the result of executing it ? public static void
The code snippet below checks whether a given number is a prime number. What will be the result of executing it
public static void mainString args
int ;
int result ;
int number ;
Scanner reader new Scanner
System.in;
System.out.printlnPlease enter a number: ;
number reader nextInt ;
while number
if number
result
j;
if result
System.out.printlnNumber: number is Not Prime.";
else
System, out.printlnNumber: number is Prime. ;
The code snippet will display the desired result.
The code snippet will loop forever.
The code snippet will display an incorrect result.
The code snippet will not compile.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
