‹ Back to the paper
Choose the correct option.
What is the statement or expression at ?2?
- (i)s * 10
- (ii)f / 10
- (iii)rev
- (iv)f * 10
Show the code
boolean Palindrome(int N)
{
int rev = ?1?;
int num = N;
while (num > 0)
{
int f = num / 10;
int s = ?2?;
int digit = num - ?3?;
rev = ?4? + digit;
num /= ?5?;
}
if(rev == N)
return true;
else
return false;
}Answer
Answer
AICorrect option: (iv)
Answer: (iv) f * 10
f = num/10, so f*10 is num with its last digit removed (zeroed).
From ISC 2022 Computer Science - Specimen paper (Semester 1), Paper 1, question 31(b).