PRASHNIKAप्रश्निका
‹ Back to the paper

The following program code checks if the positive integer ‘N’ is a palindrome number by returning…

Computer Science20221 markMCQ
The following program code checks if the positive integer ‘N’ is a palindrome number by returning true or false. There are some places in the code marked as ?1?, ?2?, ?3?, ?4? and ?5? which are to be replaced by a statement/expression so that the code works properly.
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;
}
What is the statement or expression at ?1?
  • (i)-1
  • (ii)0
  • (iii)10
  • (iv)2

Answer

No answer yet.

Implementation of algorithms to solve problems

From ISC 2022 Computer Science - Specimen paper (Semester 1), Paper 1, question 31(a).