Please help me >>>

Please .... I want this code to print on the screen the number ( 0957929396 )
I don't want where is the mistake ??? Please Help Me ...

#include<iostream>
#include<math>
#include<stdlib>
int main()
{
int x=100,H,i,j;
int S[5],N[6];
bool y=false;
for(i=1;i<4;i++){
N[i]=1/i;
if(N[i]<1) y=true;
while(y=true)
{
cout<<x<<i;
H=x-1;
i++;
if(H==i*2)
{ cout<<x<<H; break; }
}
if((x*i)%2==1)
{
x--; cout<<y<<x/10;
for(j=0;j<5;j++)
{ S[j]=x/pow(10,j+1);
x=x-S[j]*pow(10,i+1); }
cout<<j<<N[i]+j+1;
}
}
system("pause");
return 0;
}
------------------------------------
thanks a lote
pretty vauge request, could you explain more then just printing the number haha,

1
2
3
//ps use the code brackets

cout<< 0957929396<<endl;
What are you trying to do ?
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.
Last edited on
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 ..........!!!
Topic archived. No new replies allowed.