I have no idea....

Hi all.

I have a lab due and am completely stuck.
The other 4 parts were not as difficult as this part so... help!

Here is the problem...

Write a long function with one argument, long input, to return the largest factor less than the square root of the input parameter.
**Using cin or cout in this function will cost you all credit for this part.**
Write a main program to test your function. This function uses a loop starting at 2 and ends at the square root of your inputted number, testing each number until it finds a factor and then keeps track of the current largest one and returns the largest one only. If your inputted number is prime, return the initial number.


In class, he gave us the following portion..


1
2
3
4
5
6
7
#include <iostream>
#include <cmath>
using namespace std;

for (int i=2; i<(int) sqrt(input); ++i)
if (input %i ==0)
factor = i;



I am basically self teaching at this point...

Thanks so much for any help.
Looks like you should start by reviewing functions!

http://www.cplusplus.com/doc/tutorial/functions/
Topic archived. No new replies allowed.