Grade 7 Exam  >  Grade 7 Test  >  C Programming for Beginners  >  Test: Functions - Grade 7 MCQ

Functions - Free MCQ Practice Test with solutions, Grade 7 C Programming


MCQ Practice Test & Solutions: Test: Functions (10 Questions)

You can prepare effectively for Grade 7 C Programming for Beginners with this dedicated MCQ Practice Test (available with solutions) on the important topic of "Test: Functions". These 10 questions have been designed by the experts with the latest curriculum of Grade 7 2026, to help you master the concept.

Test Highlights:

  • - Format: Multiple Choice Questions (MCQ)
  • - Duration: 10 minutes
  • - Number of Questions: 10

Sign up on EduRev for free to attempt this test and track your preparation progress.

Test: Functions - Question 1

What will happen after compiling and running following code?

main()

     printf("%p", main); 
}

Detailed Solution: 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: Question 2

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

Test: Functions - Question 3

Determine output:

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

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

Detailed Solution: 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: 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: 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: 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: 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();
}

10 videos|14 docs|15 tests
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
10 videos|14 docs|15 tests
Download as PDF