NPTEL Problem Solving Through Programming In C 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: c. if (a == 1){}
else if (b == 2){}
Check Out More NPTEL Assignment Answers
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
Disclaimer: These answers are provided only for the purpose to help students to take references. This website does not claim any surety of 100% correct answers. So, this website urges you to complete your assignment yourself.
Also Available:
NPTEL Problem Solving Through Programming In C Assignment 3 Answers
NPTEL Ethical Hacking Assignment 4 Answers