C Programming Questions and Answers – Basics of Functions – 2

«
»

This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Basics of Functions – 2”.

Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.

advertisement

1. What will be the output of the following C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         m();
  5.         void m()
  6.         {
  7.             printf("hi");
  8.         }
  9.     }

a) hi
b) Compile time error
c) Nothing
d) Varies
View Answer

Answer: b
Explanation: None.
Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement
advertisement

2. What will be the output of the following C code?

Take C Programming Mock Tests - Chapterwise!
Start the Test Now: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
advertisement
  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         m();
  5.     }
  6.     void m()
  7.     {
  8.         printf("hi");
  9.         m();
  10.     }

a) Compile time error
b) hi
c) Infinite hi
d) Nothing
View Answer

Answer: c
Explanation: None.
advertisement

3. What will be the output of the following C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         static int x = 3;
  5.         x++;
  6.         if (x <= 5)
  7.         {
  8.             printf("hi");
  9.             main();
  10.         }
  11.     }

a) Run time error
b) hi
c) Infinite hi
d) hi hi
View Answer

Answer: d
Explanation: None.
advertisement

4. Which of the following is a correct format for declaration of function?
a) return-type function-name(argument type);
b) return-type function-name(argument type){}
c) return-type (argument type)function-name;
d) all of the mentioned
View Answer

Answer: a
Explanation: None.

5. Which of the following function declaration is illegal?
a) int 1bhk(int);
b) int 1bhk(int a);
c) int 2bhk(int*, int []);
d) all of the mentioned
View Answer

Answer: d
Explanation: None.

6. Which function definition will run correctly?
a)

   int sum(int a, int b)
   return (a + b);

b)

   int sum(int a, int b)
   {return (a + b);}

c)

   int sum(a, b)
   return (a + b);

d) none of the mentioned
View Answer

Answer: b
Explanation: None.

7. Can we use a function as a parameter of another function? [Eg: void wow(int func())].
a) Yes, and we can use the function value conveniently
b) Yes, but we call the function again to get the value, not as convenient as in using variable
c) No, C does not support it
d) This case is compiler dependent
View Answer

Answer: c
Explanation: None.

8. The value obtained in the function is given back to main by using ________ keyword.
a) return
b) static
c) new
d) volatile
View Answer

Answer: a
Explanation: None.

Sanfoundry Global Education & Learning Series – C Programming Language.

To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement
advertisement

Leave a Comment

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses.