I want the result of this code to be this number .... 0957929396 ....
Any way I tried more than one time to find the mistake .... ( this code have a non-stop loop )
the mistake may be here :
( S[j]=x/pow(10,j+1); )
may be in converting float number to float ....
thanks for help
There's a lot of errors I can count after fixing the first few obvious ones:
Obvious:: Its cstdlib and cmath for headers. Add the c to their names.
cmath does not define a pow(int, int) that returns an int. You'll need to write one or do some casting.
Here's an int pow(int, int)
1 2 3 4 5 6 7
int pow(int x, int n)
{
int sum = 1;
for (int i = 0; i < n; ++i)
sum = sum * x;
return sum;
}
You do some fractional division, but I don't think you realize that integer division never returns a factional part. In your loop you go 1/1 on the first go, then 1/2, which in integer division returns 0.
Not Obvious::
You have an infinite loop in the while(y = true). Mainly because A, that's an assignment operation, not a comparison operation, but also because your break condition never will happen since H will always be 99, and any i value * 2 will never be 99 by simple principles of math. Here's some output for validation of my point: Note the constant 100 being printed.
[After I noticed the output was getting odd.]
1001100210031004100510061007
. . .
10038757761003875777100387577810038757791003875780 . . .
Maybe you can explain what the code is suppose to do in context of the project, not just what the output is.
I don't know exactly how to thank you >>> I just will refer to some points :
1- pow (a,b) is a fuction in the header <math.h>
2- y=false at the beginning ... when the condition [[if(N[i]<1) y=true;]] will be implemented
3- the loop of WHILE will be broken ..... according to the condition
1 2
if(H==i*2)
{ cout<<x<<H; break; }
4- I don't know how to make this statement to return integer ... S[j]=x/pow(10,j+1)
My error is that S[i][j] will have a float number .... although it is integer ...???
***********************
Thank you for helping me ..... I'm So Sorry ... for these mistakes ..........!!!