NPTEL Problem Solving Through Programming In C Week 2 Assignment Answers 2025
1. What is the correct way to declare a constant in C?
(a) int const a;
(b) constant int a;
(c) #define a
(d) Both (a) and (c)
Answer : See Answers
2. What will be the output of the following code snippet? ‘printf(“%d”, 5 == 5);’
(a) 5
(b) 0
(c) 1
(d) True
Answer : See Answers
3. What is the size of an ‘int’ data type in C?
(a) 2 bytes
(b) Depends on the compiler
(c) 4 bytes
(d) 1 byte
Answer : See Answers
4. If an integer requires two bytes of storage, what is the maximum value of an unsigned integer in C?
a) 215 – 1
b) 216 – 1
c) 215
d) 216
Answer : See Answers
5. What is typecasting in C?
a) Assigning a value to a variable
b) Converting a variable from one data type to another
c) Defining a new data type
d) Initializing a variable with a constant value
Answer : See Answers
6. What will be the output of the following code?
#include <stdio.h>
int main() {
int a = 5, b = 10;
a = a + b;
b = a – b;
a = a – b;
printf(“d %d”, a, b);
return 0;
}
a) 10 5
b) 5 10
c) 0 15
d) Compilation error
Answer : See Answers
7. What will be the output of the following code?
#include <stdio.h>
#define SQUARE(x) x*x
int main ()
{
int result = SQUARE(2+3);
printf(“%d”, result);
return 0;
}
a) 25
b) 13
c) 11
d) Compilation error
Answer : See Answers
8. What is the purpose of the ‘return’ statement in C?
a) To terminate a loop
b) To end a program
c) To exit a function and return a value
d) To declare a variable
Answer :
9. What will happen if you try to store a value beyond the range of the declared data type of a variable in C?
(a) Compile-time error
(b) Run-time error
(c) Data loss or wrap around
(d) No error
Answer :
10.

(a) ==, !=
(b) !=, ==
(c) ==, ==
(d) <, >
Answer : See Answers


