C Programming Questions and Answers – Functions Returning Non-integers – 2

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

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

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

  1.     #include <stdio.h>
  2.     int *m();
  3.     void main()
  4.     {
  5.         int k = m();
  6.         printf("%d", k);
  7.     }
  8.     int *m()
  9.     {
  10.         int a[2] = {5, 8};
  11.         return a;
  12.     }

a) 5
b) 8
c) Nothing
d) Varies
View Answer

Answer: d
Explanation: None.
advertisement
advertisement

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

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
  1.     #include <stdio.h>
  2.     void m(int k)
  3.     {
  4.         printf("hi");
  5.     }
  6.     void m(double k)
  7.     {
  8.         printf("hello");
  9.     }
  10.     void main()
  11.     {
  12.         m(3);
  13.     }

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

Answer: c
Explanation: None.
advertisement

3. What is the default return type if it is not specified in function definition?
a) void
b) int
c) double
d) short int
View Answer

Answer: b
Explanation: None.

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

advertisement
  1.     #include <stdio.h>
  2.     int foo();
  3.     int main()
  4.     {
  5.         int i = foo();
  6.     }
  7.     foo()
  8.     {
  9.         printf("2 ");
  10.         return 2;
  11.     }

a) 2
b) Compile time error
c) Depends on the compiler
d) Depends on the standard
View Answer

Answer: a
Explanation: None.

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

  1.     #include <stdio.h>
  2.     double foo();
  3.     int main()
  4.     {
  5.         foo();
  6.         return 0;
  7.     }
  8.     foo()
  9.     {
  10.         printf("2 ");
  11.         return 2;
  12.     }

a) 2
b) Compile time error
c) Depends on the compiler
d) Depends on the standard
View Answer

Answer: b
Explanation: None.

6. Functions can return structure in C?
a) True
b) False
c) Depends on the compiler
d) Depends on the standard
View Answer

Answer: a
Explanation: None.

7. Functions can return enumeration constants in C?
a) true
b) false
c) depends on the compiler
d) depends on the standard
View Answer

Answer: a
Explanation: None.

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

  1.     #include <stdio.h>
  2.     enum m{JAN, FEB, MAR};
  3.     enum m foo();
  4.     int main()
  5.     {
  6.         enum m i = foo();
  7.         printf("%d\n", i);
  8.     }
  9.     int  foo()
  10.     {
  11.         return JAN;
  12.     }

a) Compile time error
b) 0
c) Depends on the compiler
d) Depends on the standard
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.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
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 & discussions at Telegram SanfoundryClasses.