Quiz Space

Introduction to C Programming · Qualifier · 16 Mar 2025 · January 2025 term

Question 5: Consider the following code. Let the input is a positive …

Question 5

+4 marksOne correct option

Consider the following code.

c
#include <stdio.h>
int main() {
int n, i, s = 0;
scanf("%d", &n);
for (i = 2; i < n; i++)
{
if (n % i != 0)
{
continue;
}
s += i;
}
printf("%d", s);
return 0;
}

Let the input is a positive integer in the given program. What does the code do?

  1. A

    Calculates the sum of all factors of input integer n (excluding 1 and n).

  2. B

    Calculates the sum of all non-factors of input integer n between 1 and n.

  3. C

    Calculates the sum of all odd value factors of input integer n (excluding 1 and n).

  4. D

    Calculates the sum of all even value factors of input integer n (excluding 1 and n).

Show answer

Correct answer

  • A

    Calculates the sum of all factors of input integer n (excluding 1 and n).

Question 5 of 16 in the IIT Madras BS Introduction to C Programming (Intro to C Programming) Qualifier paper sat on 16 Mar 2025, in the January 2025 term (IIT M ES QUALIFIER AN EXAM QEQ1 16 Mar 2025). It carries 4 marks.

More questions from this paper

  1. Q1What does the term "ROM" stand for in computer memory architecture?
  2. Q2Which of the following is used to terminate a C statement?
  3. Q3Consider the computations given below using the generalized memory model.\ M[0] ← x\ M[1] ← y\ M[2] ← M[0] – M[1]\ M[1]…
  4. Q4The 8-bit binary representation of decimal number -39 in 2's complement notation is .
  5. Q6Find the decimal equivalent for the unsigned binary representation (11101110)2.
  6. Q7How many maximum unique characters can be encoded using 7 bits?
  7. Q8Consider a decimal number 201. What is the 8 bit binary value of it?
  8. Q9Figure question
  9. Q10Which of the following is the correct syntax for a switch statement in C?
  10. Q11Consider the below C program. What will be the output of the above program?
  11. Q12Which of the following is/are the component(s) of a computer CPU?
  12. Q13Which of the following is/are valid identifier(s) in C?
  13. Q14Consider the below steps of computations.\ R[0] = 9\ R[1] = 0\ R[1] = R[1] + R[0]\ R[0] = R[0] - 2\ If R[0] > 0, go to …
  14. Q15Consider the following code snippet. How many times will Hello C be printed?
  15. Q16Figure question