I'm attempting to teach myself C++, and I came across this old C++ problem in my closet. It's a ripped page and I'm not sure what book it's from so it has no solution. It's easy, but I seem to have issues with while loops. If someone would explain the logic or show me an example as to how they would do it that would be much appreciated.(adsbygoogle = window.adsbygoogle || []).push({});

The problem:

-Construct a program that computes the square root of a number. Make compare the difference from your first input to your second input, and so on and so forth (for example, if the first number you input is 4, compare the square root of that to the square root of the next number you input). If the difference of the two numbers is greater than 50, terminate the program.

I have something like this:

But that gives me an "expected primary expression before" error and I'm not really sure where to proceed from here anyhow. Any help is appreciated and thanks in advance.Code (Text):#include<iostream.h>

#include<iomanip.h>

#include<math.h>

double positivePrint (double num, double square);

int main ()

{

double num, square;

positivePrint(double num, double square);

}

double positivePrint (double num, double square)

{

num==1;

while(num>0, num++);

{

square=sqrt(num);

cout << square << endl;

}

}

}

}

**Physics Forums - The Fusion of Science and Community**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# C++ Program issue

Loading...

Similar Threads - Program issue | Date |
---|---|

Programming succesive trapezoidal integrator | Friday at 3:38 PM |

What should be the rules to write excellent code? | Mar 12, 2018 |

What should I know before taking Parallel Programming? | Mar 11, 2018 |

What is each step of this Matlab program doing? | Feb 21, 2018 |

Struggling with a strange on screen format issue | Jan 9, 2018 |

**Physics Forums - The Fusion of Science and Community**