## Beginner C/C++

Moderators: None (Apply to moderate this forum)
Number of posts: 16943

This Forum Only

Whole number square roots only? Posted by RockThis52 on 2 Mar 2013 at 4:17 PM
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 <stdio.h>
#include <math.h>
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\n", x); /*The first two values of the sequence are printed here*/
printf("%d\n", y);
while (z<1000000)
{
z=x+y;
x=y;
y=z;
c++;

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

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

return (0);

}

## Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic