‹ Back to the paper
With reference to the program code given below, answer the following question: int test(int n) {…
With reference to the program code given below, answer the following question:
int test(int n)
{
if(n == 1) return 0;
for (int i = 2; i <= (int)(Math.sqrt(n)); i++)
if(n % i == 0)
return 0;
return 1;
}
What will the method test() return when the value of n=9?- (i)1
- (ii)true
- (iii)0
- (iv)Error
Answer
No answer yet.
From ISC 2022 Computer Science - Specimen paper (Semester 1), Paper 1, question 27(a).