NPTEL Problem Solving Through Programming In C Week 4 Assignment Answers 2024

Join Our WhatsApp Group Join Now
Join Us On Telegram Join Now

NPTEL Problem Solving Through Programming In C Week 4 Assignment Answers 2024

1. The loop which is executed at least once is

a) while
b) do-while
c) for
d) none of the above

Answer :- For Answer Click Here 

2. In the C programming language, negative numbers, when used in if-else conditional checking, are treated as

a) TRUE
b) FALSE
c) Depends on the implementation
d) None

Answer :- For Answer Click Here 

3. Choose a statement to use the C If Else statement.

a) else if is compulsory to use with the if statement.
b) else is compulsory to use with an if statement.
c) else or else if is optional with the if statement.
d) None of the above

Answer :- For Answer Click Here 

4. What is the output of the following C code snippet?
int a = 1;
if (a–)
printf(“Trueln”);
if (++a)
printf(“Falseln”);

a) True
b) False
c) Both ‘True’ and ‘False’
d) Compilation error

Answer :- 

5. Which of the following statements correctly describes the short-circuit behavior in logical expressions?

a) The right-hand side of an && operation is evaluated even if the left-hand side is false.
b) The right-hand side of an || operation is evaluated even if the left-hand side is true.
c) The right-hand side of an && operation is not evaluated if the left-hand side is false.
d) The right-hand side of an || operation is not evaluated if the left-hand side is true.

Answer :- 

6. Which one of the following is the correct syntax for C Ternary Operator?

a) condition? expression1 : expression2
b) condition: expression1? expression2
c) condition? expression1 < expression2
d) condition < expression1? expression2

Answer :- For Answer Click Here 

7. Given the code snippet, what will be the value of ‘a’ after execution?
int a = 5, b = 10;
a += a <= b;

a) 5
b) 6
c) 10
d) 11

Answer :- 

8. What will be the output of the code snippet?
int x = 5, y = 3;|
printi(“%d”, x > y ? x++: y++);

a) 5
b) 6
c) 3
d) 4

Answer :- 

9. What will the following code segment output?
int a = 10;
while (a– > 10) €
printi(“%od”, a);
}

a) Prints numbers from 9 to 0
b) Prints 9 only
c) No output
d) Syntax error

Answer :- 

10. What is the output of the code snippet below?
int x = 1, y = 2;
printf(“%d”, x < y? x: y, x> y? y: x);

a) 1 2
b) 2 1
c) 1
d) Compilation error

Answer :- For Answer Click Here