A community for students.
Here's the question you clicked on:
 0 viewing
Christos
 one year ago
C++
Help needed!
The program I need to build is supposed to do this:
http://screencast.com/t/qbp34sVfC
Christos
 one year ago
C++ Help needed! The program I need to build is supposed to do this: http://screencast.com/t/qbp34sVfC

This Question is Closed

Christos
 one year ago
Best ResponseYou've already chosen the best response.0// // main.cpp // week544 #include <iostream> #include <cmath> 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
 one year ago
Best ResponseYou've already chosen the best response.0This 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
 one year ago
Best ResponseYou've already chosen the best response.0You cannot use the modulus operator with a double.

Christos
 one year ago
Best ResponseYou've already chosen the best response.0what is a "modulus operator" ?

eSpeX
 one year ago
Best ResponseYou've already chosen the best response.0Use this instead: if (fmod(sqrt(a),1.0) == 0)

Christos
 one year ago
Best ResponseYou've already chosen the best response.0wait a min, but why I cant use % with doubles?

eSpeX
 one year ago
Best ResponseYou've already chosen the best response.0Because it is designed to take an integer.

Christos
 one year ago
Best ResponseYou've already chosen the best response.0hmm hold on lemme try

Anniepoo
 one year ago
Best ResponseYou've already chosen the best response.0You 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
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.