Quiz Space

Programming in C · Quiz 1 · 29 Oct 2023 · September 2023 term

Question 9: Consider the below C program. The above C program is used…

Question 9

+4 marksOne correct option

Consider the below C program.

The above C program is used to calculate the sum of individual digits of a number. For ex: If the value given to the variable “n” is 25, the sum of individual digits will be 7.
Fill in the placeholders “Expression1” and “Expression2” to ensure that the program functions correctly.

  1. A

    Expression1: r = n % 10;
    Expression2: n = r;

  2. B

    Expression1: r = n / 10;
    Expression2: n = n % 10;

  3. C

    Expression1: r = n % 10;
    Expression2: n = n / 10;

  4. D

    Expression1: n = n % 10;
    Expression2: r = n;

Show answer

Correct answer

  • C

    Expression1: r = n % 10;
    Expression2: n = n / 10;

Question 9 of 18 in the IIT Madras BS Programming in C (Programming in C) Quiz 1 paper sat on 29 Oct 2023, in the September 2023 term (IIT M DEGREE AN2 EXAM QPE2 29 Oct 2023). It carries 4 marks.

More questions from this paper

  1. Q1Which of the following is/are false statement(s) regarding C programming language?
  2. Q2Which of the following statement(s) is/are true regarding ASCII and Unicode?
  3. Q3Which of the following is/are valid identifiers in C language?
  4. Q4In split memory architecture, what is the purpose of cache memory?
  5. Q5What is the primary function of the Program Counter in a CPU?
  6. Q6Suppose you have a document which contains 58 unique characters. What is the minimum number of bits required to encode …
  7. Q7Consider the following equation: If all the variables are float, which of the following is a correct way to write the g…
  8. Q8Consider the following steps to compute the minimum among three numbers. Load the three numbers from memory locations M…
  9. Q10Compute the 9-bit binary representation of the decimal number 468.
  10. Q11Find the 8-bit binary representation of (− 50)10 using 2’s complement notation.
  11. Q12(764)10 = ()8\ Identify the appropriate option to fill in the above blank.
  12. Q13Given two integer variables, x and y, which of the following expressions ensures that both x and y are distinct positiv…
  13. Q14Consider the following code snippet. What will be the value of x, y and z after executing the given code snippet?
  14. Q15Consider the below C program. What will be the output of above given code?
  15. Q16Consider the below C program. What would be the output of the given code?
  16. Q17Consider the following assembly program (assume anything after “;” is a comment). What will be the final value stored i…
  17. Q18Consider the below C program. What would be the output of the given code?\ Note: The answer input must be an integer. F…