This set of MCQ(multiple choice questions) focuses on the Problem Solving Through Programming In C Week 8 Solutions.
Course layout (Answers Link)
Answers COMING SOON! Kindly Wait!
Week 0 : Assignment
Week 1 :Â Introduction to Problem Solving through programs
Week 2 :Â Arithmetic expressions, Relational Operations, Logical expressions; Introduction to Conditional Branching
Week 3 :Â Conditional Branching and Iterative Loops
Programming Assignment
Week 4 :Â Arranging things : Arrays
Programming Assignment
Week 5 :Â 2-D arrays, Character Arrays and StringsÂ
Programming Assignment
Week 6 :Â Basic Algorithms including Numerical Algorithms
Week 7 :Â Functions and Parameter Passing by Value
Week 8 :Â Passing Arrays to Functions, Call by Reference
Programming Assignment
Week 9 :Â Recursion
Week 10 :Â Structures and Pointers
Week 11 :Â Self-Referential Structures and Introduction to Lists
Week 12 :Â Advanced Topics
NOTE: You can check your answer immediately by clicking show answer button. Problem Solving Through Programming In C Week 8 solutions” contains 10 questions.
Now, start attempting the quiz.
Problem Solving Through Programming In C Week 8 solutions
Q1. A function prototype is used for
a) Declaring the function logic
b) Calling the function from the main body
c) Telling the compiler, the kind of arguments used in the function
d) Telling the user for proper use of syntax while calling the function
Answer: c) Telling the compiler, the kind of arguments used in the function
Q2. What is the default return type if it is not specified in function definition?
a) void
b) integer
c) double
d) float
Answer: b) integer
Q3. 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
Q4. How many times will ‘Hello world’ be printed?
#include<stdio.h>
int main() {
printf("Hello world\n");
main();
return 0;
}
a) Infinite times
b) 32767
c) 65535
d) Till stack overflows
Answer: d) Till stack overflows
Q5. How many time ‘Hi’ will be printed in the program given below?
#include<stdio.h>
int i;
int fun();
int main() {
while(i) {
fun();
main();
}
printf("Hello\n");
return 0;
}
int fun() {
printf("Hi");
}
a) Only once
b) Zero times
c) Infinite times
d) Compilation error
Answer: b) Zero times
Q6. How many times the function factorial will be executed?
Answer: 120
Q7. What will be the output?
a) 8, 4, 0, 2, 14
b) 8, 4, 0, 2, 0
c) 2, 0, 4, 8, 14
d) 2, 0, 4, 8, 0
Answer: d) 2, 0, 4, 8, 0
Q8. What is the output of the following C program?
a) 55
b) 45
c) 66
d) 10
Answer: a) 55
Q9. Consider the function
int 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
Q10. What is the output of the C code given below?
Answer: 27.08
Problem Solving Through Programming In C Week 8 solutions
Q1. What will be the output?
a) 70
b) Garbage value
c) Compilation error
d) None
Answer: c) Compilation error
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?
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?
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?
a) Choice 1
b) CChoice1
c) DefaultChoice1
d) CChoice1Choice2
Answer: b) CChoice1
Q6. What will be the output of the C code?
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?
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. 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.
Answer: 27.08
Previous Course – Week 8 assignment answers
Q1. A function prototype is used for
a) Declaring the function logic
b) Calling the function from the main body
c) Telling the compiler, the kind of arguments used in the function
d) Telling the user for proper use of syntax while calling the function
Answer: c) Telling the compiler, the kind of arguments used in the function
Q2. What is the output of the following C program?
#include<stdio.h>
void foo(), f(),
int main()
{
f();
}
void foo()
{
printf("2");
}
void f()
{
printf(" 1 ");
foo();
}
a) Compile errors 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
Q3. What is the error in the following program
#include<stdio.h>
int f(int a)
{
a > 20? return(10): return(20);
}
int main()
{
int b;
b = f(20);
printf("%d\n", b);
}
a) Error: Return statement cannot be used with conditional operators
b) Error: Prototype declaration
c) Error: Two return statements cannot be used in any function
d) No error
Answer: a) Error: Return statement cannot be used with conditional operators
Q4. 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);
}
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;
}
a) Result is=27.08
b) Result is=27.083334
c) Compiler error as result is declared twice
d) Error: Invalid prototype declaration
Answer: a) Result is=27.08
Q5. How may times the function get() will be invoked if get(6) is called from the main function
void get(int n)
{
if(n<1) return;
get(n-1);
get(n-3);
}
a) 6 times
b) 25 times
c) 12 times
d) Infinite times
Answer: b) 25 times
Q6. 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(5));
return 0;
}
a) 25
b) 5
c) 15
d) 10
Answer: c) 15
Q7. 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
Q8. What will be the output?
#include<stdio.h>
int f(int n, int k)
{
if(n==0)
return 0;
else if(n%2)
return f(n/2, 2*k) + k;
else return f(n/2, 2*k) - k;
}
int main()
{
printf("%d", f(20,1));
return 0;
}
a) 5
b) 8
c) 9
d) 20
Answer: c) 9
Q9. consider the function
int fun(x: integer)
{
if x > 100 then fun = x – 10;
else
fun = fun(fun(x+11));
}
For the input x = 95, the function will return
a) 89
b) 90
c) 91
d) 92
Answer: c) 91
Q10. If “>>” this operation right shift num(binary representation of num) by one digit. E.g., if num=60 then num>>1 is 30.
Then func(435) the value returned is
a) 9
b) 8
c) 0
d) 10
Answer: a) 9
<< Prev – An Introduction to Programming Through C Week 7 Solutions
>> Next- An Introduction to Programming Through C Week 9 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.
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.