Hello I am trying to calcuate the square digit length of a number. I have written a code but I am getting an error with the "pow" function & I have no idea what is wrong?
Can you help me?
#include <iostream>
#include <cmath>
using namespace std;
int squared_digit_length(int n1);
int main()
{
int n1= 0;
cout << "Enter a number: ";
cin >> n1;
squared_digit_length(n1);
return 0;
}
int squared_digit_length(int n1)
{
int n2, co;
while ((n2 != 1) || (n2 != 4))
{
co++;
n2 = pow(n1,2); // this is where I get my error "call of overloaded pow is ambiguous" ????
}
cout << n1 << "=" << n2 << "Count= " << co;
}
Also how would you reccommend I perform this task?
I have a number (85), and i want to pull it appart so I have 8 and 5 then I want to square each of those numbers (8^2 , 5^2) then add them (8^2 + 5^2).
I know how to do everything except separating the 85 into 8 and 5. Should I use a modulus calculation & make 85 an integer? If anyone could provide a solution in code (just the separating 85 part) I would be very greatful :)