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.

You must login to ask a question.

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

A

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

Problem Solving Through Programming In C NPTEL Assignment Answers Week 8

Q1. What will be the output?

#include <stdio.h> 
int main(){
{
int a = 70;
} 
{
printf("%d",a);
}
return 0;
}

a. 70

b. Garbage value


c. Compilation error

d. None

Answer: c. Compilation error

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


Q2. Which of the following statements are correct in C?

a. A function with the same name cannot have different signatures

b. A function with the same name cannot have different return types

c. A function with the same name cannot have a different number of parameters

d. All of the mentioned

Answer: d. All of the mentioned


Q3. What will the function return?

int func(int x, int y)

{

if (y== 0) return 0;

if (y-1) return x;

return x+func(x, y-1);

}

a. x * y where x and y are integers

b. x * y where x and y are non-negative integers

c. x + y where x and y are integers

d. x + y where x and y are non-negative integers

Answer: b. x * y where x and y are non-negative integers


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

#include <stdio.h>
void foo(), f();
int main()
{
f();
 return 0;
}
void foo()
{
printf("2 ");
}
void f()
{
printf("1 ");
foo();
}

a. Compiler error as foo() is not declared in main

b. 1 2

c. 2 1

d. Compile time error due to declaration of functions inside main

Answer: b. 1 2


Q5. What will be the output?

#include <stdio.h> 
int main()
{
switch(printf("C"))
{
default: printf("Default"); 
case 1: printf("Choice1"); break;
case 2: printf("Choice2"); break;
}
return 0;
}

a. Choice1

b. CChoice1

c. DefaultChoice1

d. CChoice1Choice2

Answer: b. CChoice1


Q6. What will be the output of the C code?

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

a. Compilation error

b. 0, 1, 2 …….., 127

c. 0, 1, 2, …….., 127, -128, -127,…infinite loop

d. 1, 2, 3…….,127

Answer: c. 0, 1, 2, …….., 127, -128, -127,…infinite loop


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

#include <stdio.h> 
int fun(int n)
{ 
int i, j, sum = 0; 
for(i = 1; i<=n; i++) 
  for(j=i; j<=i; j++) 
sum = sum + j; 
return(sum);
} 
int main() 
{
 printf("%d", fun(10));
 return 0;
}

a. 55

b. 45

c. 66

d. 10

Answer: a. 55


Q8. Consider the function

find(int x, int y)
{
return((x<y)? 0: (x-y));
}

Let a and b be two non-negative integers. The call find(a, find(a, b)) can be used to find the

a. Maximum of a, b

b. Positive difference between a and b

c. Sum of a and b

d. Minimum of a and b

Answer: d. Minimum of a and b


Q9.

int fibonacci(int n)
{
switch(n)
{
default:return (fibonacci(n - 1) + fibonacci(n-2));
case 1:
case 2:
}
return 1;
}

The function above has a flaw that may result in a serious error during some invocations.

Which one of the following describes the deficiency illustrated above?

a. For some values of n, the environment will almost certainly exhaust its stack space before the calculation completes.

b. An error in the algorithm causes unbounded recursion for all values of n.

c. A break statement should be inserted after each case. Fall-through is not desirable here.

d. The fibonacci() function includes calls to itself. This is not directly supported by Standard C due to its unreliability.

Answer: a. For some values of n, the environment will almost certainly exhaust its stack space before the calculation completes.


Q10. What is the output of the C code given below

#include <stdio.h> 
float func(float age[ ]);
int main(){
float result, age[] = { 23.4, 55, 22.6, 3, 40.5, 18};
 result = func(age);
 printf("Result is %0.2f", result);
return 0;
}
float func(float age[])
{
int i;
float result, sum = 0.0; 
for (i=0; i<6; ++i) 
{ 
sum += age[i];
} 
result = (sum/6); 
return result;
}

Answer: 27.08


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 7

Related Posts