Class 6 Exam  >  Class 6 Tests  >  Test: Functions - Class 6 MCQ

Test: Functions - Class 6 MCQ


Test Description

10 Questions MCQ Test - Test: Functions

Test: Functions for Class 6 2024 is part of Class 6 preparation. The Test: Functions questions and answers have been prepared according to the Class 6 exam syllabus.The Test: Functions MCQs are made for Class 6 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: Functions below.
Solutions of Test: Functions questions in English are available as part of our course for Class 6 & Test: Functions solutions in Hindi for Class 6 course. Download more important topics, notes, lectures and mock test series for Class 6 Exam by signing up for free. Attempt Test: Functions | 10 questions in 10 minutes | Mock test for Class 6 preparation | Free important questions MCQ to study for Class 6 Exam | Download free PDF with solutions
Test: Functions - Question 1

What will happen after compiling and running following code?

main()

     printf("%p", main); 
}

Detailed Solution for Test: Functions - Question 1

Function names are just addresses (just like array names are addresses).
main() is also a function. So the address of function main will be printed. %p in printf specifies that the argument is an address. They will be printed as hexadecimal numbers.

Test: Functions - Question 2

Any C program

Detailed Solution for Test: Functions - Question 2

At least one function which must be included in any C program is main().

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: Functions - Question 3

Determine output:

main()
{
      int i = abc(10);
      printf("%d", --i);
}

int abc(int i)
{
      return(i++);
}

Detailed Solution for Test: Functions - Question 3

return(i++) it will first return i and then increment. i.e. 10 will be returned.

Test: Functions - Question 4

What is the result of compiling and running this code?

main()
{
      char string[] = "Hello World";
      display(string);
}

void display(char *string)
{
      printf("%s", string);
}

Detailed Solution for Test: Functions - Question 4

Compiler Error : Type mismatch in redeclaration of function display
As the function display() is not defined before use, compiler will assume the return type of the function which is int(default return type). But when compiler will see the actual definition of display(), mismatch occurs since the function display() is declared as void. Hence the error.

Test: Functions - Question 5

What will be the output of the following program code?

main()
{
      static int var = 5;
      printf("%d ", var--);
      if(var)
            main();
}

Detailed Solution for Test: Functions - Question 5

When static storage class is given, it is initialized once. The change in the value of a static variable is retained even between the function calls. Main is also treated like any other ordinary function, which can be called recursively.

Test: Functions - Question 6

What will be printed when this program is executed?

int f(int x)
{
   if(x <= 4)
      return x;
   return f(--x);
}
void main()
{
   printf("%d ", f(7)); 
}

Detailed Solution for Test: Functions - Question 6

In this recursive function call the function will return to main caller when the value of x is 4. Hence the output.

Test: Functions - Question 7

Which of the following function calculates the square of 'x' in C?

Test: Functions - Question 8

When a function is recursively called all the automatic variables are stored in a ..........

Test: Functions - Question 9

What is the output of this C code?

int main()
{
void foo();
void f()
{
foo();
}
f();
}
void foo()
{
printf("2 ");
}

Detailed Solution for Test: Functions - Question 9

Even though the answer is 2, this code will compile fine only with gcc. GNU C supports nesting of functions in C as a language extension where as standard C compiler doesn't.

Test: Functions - Question 10

What is the output of this C code?

void m()
{
printf("hi");
}
void main()
{
m();
}

Information about Test: Functions Page
In this test you can find the Exam questions for Test: Functions solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Functions, EduRev gives you an ample number of Online tests for practice

Top Courses for Class 6

Download as PDF

Top Courses for Class 6