# Problem Solving Through Programming In C NPTEL Week 5 Solutions

This set of MCQ(multiple choice questions) focuses on the Problem Solving Through Programming In C NPTEL Week 5 Solutions.

NOTE: You can check your answer immediately by clicking show answer button. Problem Solving Through Programming In C NPTEL Week 5 assignment answers” contains 10 questions.

Now, start attempting the quiz.

### Problem Solving Through Programming In C NPTEL Week 5 assignment answers

Q1. The statement that transfers control to the beginning of the loop is called

a) break
b) continue
c) goto
d) None of the above

Q2. In C three way transfer of control is possible using

a) Unary operator
b) Logical operator
c) Ternary operator
d) None

Q3. What is the output of the following code?

a) ‘while vs d-while’ once
b) ‘Out of loop’ infinite times
c) Both ‘while vs d-while’ and ‘Out of loop’ once
d) ‘while vs do-while’ infinite times

Answer: d) ‘while vs do-while’ infinite times

Q4. What is the output of the following C program?

a) 5
b) 10
c) No output
d) Compilation error

Q5. What is the output o the following C code?

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

Answer: c) Both ‘True’ and ‘False’

Problem Solving Through Programming In C NPTEL Week 5 assignment answers

Q6. What will be the output?

a) After loop x=1
b) 1
After loop x=2
c) 1 2 3 4 5 6 7 8 9 10
d) No output

Q7. What will be the output?

a) Error
b) I love C – will be printed 3 times
c) I love C – will be printed 6 times
d) I love C – will be printed 5 times

Answer: b) I love C – will be printed 3 times

Problem Solving Through Programming In C NPTEL Week 5 assignment answers

Q8. What will be the output?

``````#include<stdio.h>
int main()
{
int x;
x = 4 < 8 ? 5 != 1 < 5 == 0 ? 1: 2: 3;
printf("%d", x);
return 0;
}``````

a) 1
b) 2
c) 3
d) Error

Problem Solving Through Programming In C NPTEL Week 5 assignment answers

Q9. The following program is used to find the reverse of a number using C language. Find the missing condition inside while statement (indicated as ‘xxxx’).

a) n!=0
b) n==0
c) n%10==0
d) n/10==0

Q10. Compute the printed value of i & j of the C program given below

a) 8, 10
b) 8, 9
c) 6, 9
d) 7, 10

Problem Solving Through Programming In C NPTEL Week 5 assignment answers

### Problem Solving Through Programming In C NPTEL Week 5 assignment answers

Q1. What will be the output?

a) 10 9 8 7 6 5 4 3 2 1
b) 1 2 3 4 5 6 7 8 9 10
c) No output
d) None of the above statements are correct

Q2. Which of the following is not an infinite loop?

a) for(; 😉
b) for(x=0, x<=10)
c) while(1)
d) while(0)

Q3. Consider the following and identify the false statement(s)?

a) (i) and (ii)
b) (i), (ii) and (iv)
c) (ii)
d) (ii) and (iv)

Q4. Compute the printed value of ‘m’ and ‘n’ of the C program given below.

a) 5, 7
b) 5, 5
c) 7, 7
d) 0, 0

Q5. What should be in the place of ***** so that except i=8, rest of the values of i (as defined in the ‘for’ loop: i=0 to i=19) will be printed?

a) break
b) continue
c) switch
d) exit

Problem Solving Through Programming In C NPTEL Week 5 assignment answers

Q6. What will be the output?

a) NPTEL
b) IIT/IISc
c) NPTELSWAWAMIIT/IISc
d) Compilation error

Q7. What will be the output?

a) 1, 3
b) 1, 3
3, 1
c) 1, 3
2, 2
3, 1
d) 0, 0

Problem Solving Through Programming In C NPTEL Week 5 assignment answers

Q8. What will be the output of the program?

a) 4 will print 1 times
b) 4 will print 3 times
c) 4 will print 4 times
d) No output

Answer: b) 4 will print 3 times

Problem Solving Through Programming In C NPTEL Week 5 assignment answers

Q9. For the C program given below, if the input given by the user is 7. What will be shown on the output window?

a) The number is odd
b) The number is prime
c) The number is odd The number is prime
d) Syntax Error

Answer: b) The number is prime

Q10. What will be the output?

a) 0 1 2 3 4 5 6 7 8 9 11 12…..infinite times
b) 1 2 3 4 5 6 7 8 9 11 12….infinite times
c) Won’t print anything
d) Error

Problem Solving Through Programming In C NPTEL Week 5 assignment answers

### Previous Course – Week 5 assignment answers

Q1. Continue statement used

a) to continue to the next line of code
b) to debug
c) to stop the current iteration and begin the next iteration from the beginning
d) None of the above statements are correct

Answer: c) to stop the current iteration and begin the next iteration from the beginning

Q2. What will be the output?

``````#include<stdio.h>
int main()
{
if((0 && 1)||(1 && -1))
printf("Condition is true.");
else
printf("Condition is false.");
return 0;
}``````

a) Condition is true
b) Condition is false
c) Compilation Error
d) No output possible

Q3. Compute the printed value of i of the C program given below

``````#include<stdio.h>

int main()
{
int i = 0, j = 0;
while(i<4, j<5)
{
i++;
j++;
}
printf("%d, %d\n", i, j);
return 0;
}``````

a) 4, 5
b) 4, 4
c) 5, 5
d) 0, 0

Q4. What will be the output?

``````#include<stdio.h>

int main()
{
switch(printf("IIT"))
{
default:
printf(" Guwahati");
case 1: printf(" Delhi");
break;
case 2: printf(" Kharagpur");
break;
break;
}
return 0;
}``````

a) IIT Delhi
b) IIT Kharagpur
d) IIT Guwahati

Q5. Find the output of the following C program.

``````#include<stdio.h>

int main()
{
int i = 0;
if(i==0)
{
i = i + 1;
break;
}
printf("%d", i);
return 0;
}``````

a) 0
b) 1
c) No output
d) Compiler error

Problem Solving Through Programming In C NPTEL Week 5 solutions

Q6. What will be printed when the following code is executed?

``````#include<stdio.h>

int main()
{
int i=0;
for(;i<=9;)
{
i++;
printf("%d", i);
}
return 0;
}``````

a) 0 1 2 … 9
b) 0 1 2 … 10
c) 1 2 3 … 9
d) 1 2 3 … 10

Answer: d) 1 2 3 … 10

Q7. What is the output of the below C program?

``````#include<stdio.h>

int main()
{
short int k=1, j=1;
while(k <= 4 || j <=3)
{
k = k + 2;
j += 1;
}
printf("%d,%d", k,j);
return 0;
}``````

a) 5, 4
b) 7, 4
c) 5, 6
d) 6, 4

Problem Solving Through Programming In C NPTEL Week 5 solutions

Q8. What will be the output?

``````#include<stdio.h>

int main()
{
int i=0;
for(;;)
{
if(i==10)
continue;
printf("%d", ++i);
}
return 0;
}``````

a) 0 1 2 3 4 5 6 7 8 9 11 12 … infinite times
b) 1 2 3 4 5 6 7 8 9 11 12 … infinite times
c) Nothing will be printed
d) Compilation Error

Answer: c) Nothing will be printed

Problem Solving Through Programming In C NPTEL Week 5 solutions

Q9. What will be the output?

``````#include<stdio.h>

int main()
{
int x=1;
do
{
x++;
continue;
printf("%d", x);
break;
}while(x<=2);
printf("\nAfter loop x=%d", x);
printf("\n");
return 0;
}``````

a) After loop x=1
b) 1
After loop x=2
c) 1 2
After loop x=3
d) After loop x=3

Q10. What will be the output?

``````#include<stdio.h>

int main()
{
int x;
x = 4 > 8 ? 5 !=1 < 5 == 0 ? 1:2:3;
printf("%d", x);
return 0;
}``````

a) 1
b) 2
c) 3
d) Error

Problem Solving Through Programming In C NPTEL Week 5 solutions

<< Prev – An Introduction to Programming Through C Week 4 Solutions

>> Next- An Introduction to Programming Through C Week 6 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 – 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.