This set of MCQ(multiple choice questions) focuses on the Problem Solving Through Programming In C NPTEL Week 4 Solutions.
Course layout (Answers Link)
Answers COMING SOON! Kindly Wait!
Week 0 : Assignment
Week 1 : Introduction to Problem Solving through programs
Week 2 : Arithmetic expressions, Relational Operations, Logical expressions; Introduction to Conditional Branching
Week 3 : Conditional Branching and Iterative Loops
Programming Assignment
Week 4 : Arranging things : Arrays
Programming Assignment
Week 5 : 2-D arrays, Character Arrays and Strings
Programming Assignment
Week 6 : Basic Algorithms including Numerical Algorithms
Week 7 : Functions and Parameter Passing by Value
Week 8 : Passing Arrays to Functions, Call by Reference
Programming Assignment
Week 9 : Recursion
Week 10 : Structures and Pointers
Week 11 : Self-Referential Structures and Introduction to Lists
Week 12 : Advanced Topics
NOTE: You can check your answer immediately by clicking show answer button. Problem Solving Through Programming In C NPTEL Week 4 assignment answers” contains 10 questions.
Now, start attempting the quiz.
Problem Solving Through Programming In C NPTEL Week 4 assignment answers
Q1. What is the purpose of the “if-else” statement in C?
a) To execute a block of code repeatedly.
b) To declare variables and constants.
c) To test a condition and execute different code based on the result.
d) To perform mathematical calculations.
Answer: c)
Q2. What is the correct syntax for an “if-else” statement in C?
a) if condition { statement 1; statement 2; } else { statement 3; }
b) if condition then { statement 1; } else { statement 2; }
c) if (condition) { statement 1; } else { statement 2; }
d) if condition then statement 1; else statement 2;
Answer: c)
Q3. Which of the following is true about nested “if-else” statements?
a) They are not allowed in C.
b) The “else” part is mandatory for every “if” statement.
c) They allow you to test multiple conditions and execute different blocks of code based on the results.
d) Nested “if-else” statements are only allowed up to two levels deep.
Answer: c)
Q4. What happens if there is no “else” part in an “if-else” statement?
a) The program will not compile.
b) The program will crash at runtime.
c) If the condition is true, nothing happens; if the condition is false, the program crashes.
d) If the condition is true, the program executes the code inside the “if” block; if the condition is false, nothing happens.
Answer: d)
Q5. Which of the following operators can be used to combine multiple conditions in an “if” statement?
a) && (logical AND)
b) ||(logical OR)
c) !(logical NOT)
d) All of the above
Answer: d)
Q6. Compute the printed value of i of the C program given below
a) 2
b) 3
c) 4
d) Compiler error
Answer: a)
Q7. If multiple conditions are used in a single “if” statement then the testing of those conditions are done
a) From Right to Left
b) From Left to right
c) Randomly
d) None of the above
Answer: b)
Q8. What is the purpose of the given program? n is the input number given by the user.
a) Sum of the digits of a number
b) The negative sum of the digits of a number
c) The reverse of a number
d) The same number is printed
Answer: b)
Q9. What will be the value of a, b, c after the execution of the followings
int a=5, b=7, c=111;
c/=++a * b–;
a) a=5, b=6, c=2;
b) a=6, b=7, c=1;
c) a=6, b=6, c=2;
d) a=5, b=7, c=1;
Answer: c)
Q10. What will be the output of the following program?
a) Choice is 1
b) Choice other than 1
c) Both a and b
d) Syntax error
Answer: c)
Problem Solving Through Programming In C NPTEL Week 4 assignment answers
Q1. The loop which is executed at least once is
a) “while” loop
b) “do-while” loop
c) “for” loop
d) None of the above
Answer: b) “do-while” loop
Q2. 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 of these
Answer: a) TRUE
Q3. Choose the correct statement to use “if-else” statement in C Language
a) “else if” is compulsory to use with “if” statement
b) “else” is compulsory to use with “if” statement
c) “else” or “else if” is optional with the “if” statement
d) None of the above are correct
Answer: c) “else” or “else if” is optional with the “if” statement
Q4. What is the output of the following C code?
a) True
b) False
c) both ‘True’ and ‘False’ are printed
d) Compilation error
Answer: c) both ‘True’ and ‘False’ are printed
Q5. In the following example, tell which statement is correct
if((condition1==1)&&(condition2==1))
printf(“Swayam”);
a) Condition1 will be evaluated first, and condition2 will be evaluated second
b) Condition2 will be evaluated first, and condition1 will be evaluated second
c) Condition1 will be evaluated first, condition2 will be evaluated only if the condition1 is TRUE
d) Condition2 will be evaluated first, and condition1 will be evaluated only if condition2 is TRUE
Answer: c) Condition1 will be evaluated first, condition2 will be evaluated only if the condition1 is TRUE
Q6. Which one of the following is the correct syntax for Ternary Operator in C language?
a) condition ? expression1 : expression2
b) condition : expression1 ? expression2
c) condition ? expression1 < expression2
d) condition < expression1 ? expression2
Answer: a) condition ? expression1 : expression2
Q7. The purpose of the following program fragment is to
a) Transfer the content of s to b
b) Transfer the content of b to s
c) Exchange (swap) the content of s and b
d) Negate the contents of s and b
Answer: c) Exchange (swap) the content of s and b
Q8. What will be the output?
a) 11
b) 33
c) 31
d) 13
Answer: c) 31
Q9. What will be the output? (&& is logical AND operation)
a) 0
1 2
b) 1
1 1
c) 0
0 0
d) 0
1 1
Answer: d)
Q10. What will be the value of a, b, and c after the execution of the following
int a=5, b=7, c=111;
c/=++a*b–;
a) a=5, b=6, c=2;
b) a=6, b=7, c=1;
c) a=6, b=6, c=2;
d) a=5, b=7, c=1;
Answer: c) a=6, b=6, c=2;
Previous Course – Week 4 assignment answers
Q1. In the C program, ‘&’ is used in ‘scanf’ to indicate
a) AND operation
b) Memory location
c) Value of the variable
d) Value at the memory location.
Answer: b) Memory location
Q2. The control/conditional statements used in C is/are
a) if-else statements
b) switch statements
c) Both (a) and (b)
d) None of these
Answer: c) Both (a) and (b)
Q3. What is the other statement that can avoid multiple nested if conditions?
a) Functions
b) Switch statements
c) If-else statements with ‘break’
d) Loop statements
Answer: b) Switch statements
Q4. The loop which is executed at least one is
a) while
b) do-while
c) for
d) none of the above
Answer: b) do-while
Q5. if (a == 1||b == 2){} can be written as:
a) if (a == 1)
if (b == 2){}
b) if (a == 1){}
if (b == 2){}
c) if (a == 1){}
else if (b == 2){}
d) none of the mentioned
Answer: a)
Q6. What will be the output of the following code
int main()
{
int x, y = 5, z = 5;
x = y == z;
printf("%d", x);
return 0;
}
a) 5
b) 1
c) 0
d) None of these
Answer: b) 1
Q7. Which statement is correct for the following lines?
switch(temperatureInCelsius)
{
case<35:
printf("hot day!");
default:
printf("not that hot day!");
}
a) It’s perfectly fine
b) It will print both statements
c) It will give a compilation error
d) More information required
Answer: c) It will give a compilation error
Q8. What will be the output of the given program?
#include<stdio.h>
void main()
{
float num=5.6;
switch(num){
case 5: printf("5");
case 6: printf("6");
default: printf("0");
break;
}
printf("%d", num);
}
a) 5 5.600000
b) 6 5.600000
c) 5 6 0 5.600000
d) Compile error
Answer: d) Compile error
Q9. What will be the value of a, b, c after execution of the followings
int a=5, b=7, c=111;
c/=++a*b–;
a) a=5, b=6, c=2
b) a=6, b=7, c=1
c) a=6, b=6, c=2
d) a=5, b=7, c=1
Answer: c) a=6, b=6, c=2
Q10. What will be output of the following program?
#include<stdio.h>
int main(){
int a=0, b=10;
if(a=0){
printf("true");
}
else{
printf("false");
}
return 0;
}
a) true
b) false
c) 0
d) 1
Answer: b) false
<< Prev – An Introduction to Programming Through C Week 3 Solutions
>> Next- An Introduction to Programming Through C Week 5 Solutions
DISCLAIMER: Use these answers only for the reference purpose. Quizermania doesn't claim these answers to be 100% correct. So, make sure you submit your assignments on the basis of your knowledge.
Programming in Java NPTEL week 1 quiz answers
NPTEL – Python for Data Science assignment solutions
Nptel – Deep Learning assignment solutions
For discussion about any question, join the below comment section. And get the solution of your query. Also, try to share your thoughts about the topics covered in this particular quiz.
Bro 5 me C ayega