Sign Up

Sign In

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Sorry, you do not have permission to ask a question, You must login to ask a question.

SIKSHAPATH Latest Articles

Problem Solving Through Programming In C NPTEL Assignment Answers Week 5 2022

A

Students, are you looking for help in problem solving through programming in C NPTEL week 5 assignment answers? So, here in this article, we have provided problem solving through programming in C week 5 assignment answer’s hint.

Problem Solving Through Programming In C NPTEL Assignment Answers Week 5

Q1. What will be the output?

#include <stdio.h> 
int main()
{
 int n;
 for(n=10; n<10; n--)
 printf("%d", n);
 return 0;
}

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

Answer: c. No output

800+ Students are taking advantage of instant notification, Join us on telegram.


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

a. for(;;)

b. for(x=0; x<=10)

c. while(1)

d. while(0)

Answer: d. while(0)


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

i. ‘do-while loop must be terminated by a semi colon.

ii. ‘do-while’ loop is always an infinite loop.

iii. Even if the condition is false, the ‘do-while’ loop executes once.

iv. ‘do-while’ loop is an entry-controlled loop.

a. (i) and (ii)

b. (i), (ii), and (iv)

c. (ii)

d. (ii) and (iv)

Answer: d. (ii) and (iv)


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

#include <stdio.h> 
int main()
{ 
int m= 0, n = 0;
 while (m<5, n<7)
{
  m++;

  n++;
} 
 printf("%d, %d\n", m, n);
 return 0;
}

a. 5, 7

b. 5, 5

c. 7, 7

d. 0, 0

Answer: c. 7, 7


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?

#include <stdio.h>
int main(
{
int i = 0;
for (i=0; i<20; i++)
{
if(i==8)
{

 **********
}
printf("i=%d\n",i);
}
return 0;
}

a. break

b. continue

c. switch

d. exit

Answer: b. continue


Q6. What will be the output?

#include <stdio.h> 
int main()
{
int x = 0; 
switch(x)
{
case 0: printf("NPTEL");
case 1: printf("SWAWAM"); 
default: printf("IIT/IISc");
}
return 0;
}

a. NPTEL

b. IIT/IISc

c. NPTELSWAWAMIIT/IISc

d. Compilation error

Answer: c. NPTELSWAWAMIIT/IISc


Q7. What will be the output?

#include<stdio.h> 
int main()
{
int k, j;
for(k=1,j=3; k<=3,j>=1;k++,j--)
{
printf("%d,%d\n",k,j);
}
return 0;
}

a. 1,3

b. 1,3

3,1

c. 1,3
    2,2
    3,1

d.  0,0

Answer: Option C


Q8. What will be the output of the program?

#include <stdio.h>
int main()
{
int p;
for (p=0; p<3; p++)
{
 int p=4;
 printf("%d,",p);
}
return 0;
}

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


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

#include <stdio.h> 
int main()
{ 
int n,i=2;
scanf("%d",&n);
do
{
if(n%i==0)
{
printf("The number is odd");
}
i++;

}while(i<n);
 printf("The number is prime");
   return 0;
}

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?

#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. Won’t print anything

d. Error

Answer: c. Won’t print anything


TELEGRAM FOR NOTIFICATIONClick 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 4

Related Posts