Students, are you looking for help in problem solving through programming in C NPTEL week 4 assignment answers? So, here in this article, we have provided problem solving through programming in C week 4 assignment answer’s hint.
Problem Solving Through Programming In C NPTEL Assignment Answers Week 4
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
For instant notification of any updates, Join us on telegram.
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?
#include <stdio.h>
int main(){
int a = 1;
if(a--)
printf("True\n");
if(++a)
printf("False\n");
return 0;
}
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
b=s+b;
s=b-s;
b=b-s;
(where s and b are two integers)
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?
#include <stdio.h>
int main(){
int x=0;
x = printf("3");
printf("%d",x);
return 0;
}
a. 11
b. 33
c. 31
d. 13
Answer: c. 31
Q9. What will be the output? (&& is logical AND operation)
#include <stdio.h>
int main() {
int i=0,j=1;
printf("\n %d", i++ && ++j);
printf("\n %d %d", i,j);
return 0;
}
a. 0
1 2
b. 1
1 1
c. 0
0 0
d. 0
1 1
Answer: Option 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;
| TELEGRAM FOR NOTIFICATION | Click Here |
| Follow on Google News (in one click) | Click Here |
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:
Problem Solving Through Programming In C NPTEL Assignment Answers Week 3
Problem Solving Through Programming In C NPTEL Assignment Answers Week 5