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

«
»

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

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

advertisement

1. What is the return-type of the function sqrt()?
a) int
b) float
c) double
d) depends on the data type of the parameter
View Answer

Answer: c
Explanation: None.

2. Which of the following function declaration is illegal?
a)

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
advertisement
advertisement
   double func();
   int main(){}
   double func(){}

b)

advertisement
   double func(){};
   int main(){}

c)

advertisement
   int main()
   {
       double func();
   }
   double func(){//statements}

d) None of the mentioned
View Answer

Answer: d
Explanation: None.
advertisement

3. What will be the output of the following C code having void return-type function?

  1.     #include <stdio.h>
  2.     void foo()
  3.     {
  4.         return 1;
  5.     }
  6.     void main()
  7.     {
  8.         int x = 0;
  9.         x = foo();
  10.         printf("%d", x);
  11.     }

a) 1
b) 0
c) Runtime error
d) Compile time error
View Answer

Answer: d
Explanation: None.

4. What will be the data type returned for the following C function?

  1.     #include <stdio.h>
  2.     int func()
  3.     {
  4.         return (double)(char)5.0;
  5.     }

a) char
b) int
c) double
d) multiple type-casting in return is illegal
View Answer

Answer: b
Explanation: None.

5. What is the problem in the following C declarations?

   int func(int);
   double func(int);
   int func(float);

a) A function with same name cannot have different signatures
b) A function with same name cannot have different return types
c) A function with same name cannot have different number of parameters
d) All of the mentioned
View Answer

Answer: d
Explanation: None.

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

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

a) hello5
b) Error
c) Nothing
d) Junk value
View Answer

Answer: a
Explanation: None.

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

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

a) 5
b) Junk value
c) 0
d) Error
View Answer

Answer: a
Explanation: None.

8. 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("hello ");
  7.         printf("%d", k[0]);
  8.     }
  9.     int *m()
  10.     {
  11.         int a[2] = {5, 8};
  12.         return a;
  13.     }

a) hello 5 8
b) hello 5
c) hello followed by garbage value
d) Compilation error
View Answer

Answer: c
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.