C Programming Questions and Answers – Type Conversions – 1

This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Type Conversions – 1”.

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.     void main()
  3.     {
  4.         float x = 0.1;
  5.         if (x == 0.1)
  6.             printf("Sanfoundry");
  7.         else
  8.             printf("Advanced C Classes");
  9.     }

a) Advanced C Classes
b) Sanfoundry
c) Run time error
d) Compile time error
View Answer

Answer: a
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 main()
  3.     {
  4.         float x = 0.1;
  5.         printf("%d, ", x);
  6.         printf("%f", x);
  7.     }

a) 0.100000, junk value
b) Junk value, 0.100000
c) 0, 0.100000
d) 0, 0.999999
View Answer

Answer: b
Explanation: None.

3. What will be the output of the following C code? (Initial values: x= 7, y = 8)

advertisement
  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         float x;
  5.         int y;
  6.         printf("enter two numbers \n");
  7.         scanf("%f %f", &x, &y);
  8.         printf("%f, %d", x, y);
  9.     }

a) 7.000000, 7
b) Run time error
c) 7.000000, junk
d) Varies
View Answer

Answer: c
Explanation: None.

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

advertisement
  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         double x = 123828749.66;
  5.         int y = x;
  6.         printf("%d\n", y);
  7.         printf("%lf\n", y);
  8.     }

a) 0, 0.0
b) 123828749, 123828749.66
c) 12382874, 12382874.0
d) 123828749, 0.000000
View Answer

Answer: d
Explanation: None.

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

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         int x = 97;
  5.         char y = x;
  6.         printf("%c\n", y);
  7.     }

a) a
b) b
c) 97
d) Run time error
View Answer

Answer: a
Explanation: None.

6. When double is converted to float, then the value is?
a) Truncated
b) Rounded
c) Depends on the compiler
d) Depends on the standard
View Answer

Answer: c
Explanation: None.

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

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         unsigned int i = 23;
  5.         signed char c = -23;
  6.         if (i > c)
  7.             printf("Yes\n");
  8.         else if (i < c)
  9.             printf("No\n");
  10.     }

a) Yes
b) No
c) Depends on the compiler
d) Depends on the operating system
View Answer

Answer: b
Explanation: None.

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

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 23;
  5.         char c = -23;
  6.         if (i < c)
  7.             printf("Yes\n");
  8.         else
  9.             printf("No\n");
  10.     }

a) Yes
b) No
c) Depends on the compiler
d) Depends on the standard
View Answer

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