LearnFrenzy
Sign in Take a free test

Operators and Expressions · Operators MCQ · Question 12

Can % be used with double in C? Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 12 Back to Exercise

What happens with double r = 7.5 % 2;?

  • A r is 1.5
  • B A compile error: % needs integer operands; use fmod() Correct
  • C r is 1
  • D r is 0
Correct Answer: Option B

The % operator is defined only for integer types. fmod(7.5, 2) from <math.h> gives 1.5.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links