I have a program done which works, but for some reason it seems like it could be more concise. I would love any suggestions as to how to make this better. Also, I am getting the following warning:
"39 [Warning] converting to `int' from `double' "
I am curious if this warning is due to a syntax error. If so what would be the best way to fix it. Thanks in advance for any suggestions. The scope of the program is to have a user enter a positive integer and tell the user whether the integer is prime or not.
Basically, the sqrt function returns a double value and you're storing it in an integer. That means that anything after the decimal point will be truncated, potentially leading to unwanted answers.
As ResidentBiscuit says, the fix is to make the value you're holding a result in a double, presuming you want an accurate representation of the square root result. If you did just want to retain an integer value and not have the warning, you'd just need to explicitly cast the data type.
Thanks for the explanation. I believe i will leave it the way it is then. It works for me and i need to divide by an integer anyway when i look for primeness. Glad to see all these great minds looking to help out us newbies looking to get into this field.