1)Implement square() without using the multiplication operator; that is, do the x*x by repeated addition (start a variable result at 0 and add x to it x times).
2) Then run some versions of "the first program" using that square().
I think that to implement part 1 I need to use a for loop? Here is something I put together
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
usingnamespace std;
int main()
{
int square(int x)
{
int x=0; // Starts a variable result at 0
returnfor (int x=0;x==x;x+=x) // adds x to it x times
++x;
}
}
I haven`t had much time lately but here is the code with at leat (hopefully) a definition a square followed by a main function where I use this square that I just implemented: