Christos
  • Christos
C++ Help needed! The program I need to build is supposed to do this: http://screencast.com/t/qbp34sVfC
Computer Science
katieb
  • katieb
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

Christos
  • Christos
// // main.cpp // week5-4-4 #include #include using namespace std; int main() { double a; cin >> a; if (sqrt(a)%1.0 == 0) cout << "It's an integer."; else cout << "It's NOT an integer. Sorry."; return 0; }
Christos
  • Christos
This is the code I created for the problem. I don't know why it doesn't run. Can you help me spot the problem?
eSpeX
  • eSpeX
You cannot use the modulus operator with a double.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

Christos
  • Christos
what is a "modulus operator" ?
eSpeX
  • eSpeX
%
eSpeX
  • eSpeX
Use this instead: if (fmod(sqrt(a),1.0) == 0)
Christos
  • Christos
wait a min, but why I cant use % with doubles?
eSpeX
  • eSpeX
Because it is designed to take an integer.
Christos
  • Christos
hmm hold on lemme try
anonymous
  • anonymous
You might also have trouble with the == it's always iffy to compare doubles. think of all the times a computer's told you 2.0 + 2.0 = 3.99999999

Looking for something else?

Not the answer you are looking for? Search for more explanations.