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.

advertisement

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?

advertisement
  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.

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!

advertisement
advertisement

Leave a Comment

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter

Check his free tutorial videos on Advanced C Programming. Join his Sanfoundry-Classes telegram channel for all videos and queries on Programming, Data-Structures, Kernel, Personality development and Mentoring.