#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Whole number square roots only?

Posts: 4Member
I need to write a program that will list the fibonacci sequence up until a million (This part is done) and then out of the numbers, I need to take the square roots, and only print the ones that return whole numbers, if I take the square roots of each number (being int's, It will return all the answers rounded to the nearest whole number, which is not what I need. Since I don't even know where to begin on this, I have no code implementing the square root portion. Not asking for it to be done for me , just where do I start maybe? Thanks

Language - C

#include
#include
int main(void)
{

int x, y, z,c,s;
double d;

x=1; /*Initiating the first values of the fibonacci sequence*/
y=1;
z=0;
c=1; /*Initiating the first value for the count*/

printf("%d
", x); /*The first two values of the sequence are printed here*/
printf("%d
", y);
while (z<1000000)
{
z=x+y;
x=y;
y=z;
c++;

if (z<1000000)
printf("%d
", z);

}
printf("The amount of numbers in the follwing sequence is %d
", c);

return (0);

}
· ·
Sign In or Register to comment.