void main()
  int i,j;
  /*input values of i and j*/
    do something;

> is this loop tends to infinity for any value of i and j
Like any pair of positive numbers?

1. int main() 2. Nope. For any initial i and j the loop runs until i or j comes to zero (for positive initial number - after integer overflow). Of course on 64-bit platform it's a long way to...

dhingra initialize i and j in the previous comment statement ;)

Oh, so the code he posted is not the same as the code that is giving the problem(s).


That loop it is an absurdity.
In the best case if the product of i * j is a negative number the pre-increment of i would always be something other than seven and the post-increment of j something other than nine.

At the other hand. If the product it is a positive number then that's it, the loop doesn't need to check anything else.

May be it was a test on logics and theory of binary arithmetics?..
Sometimes I think that 9 of 10 questions on the C and C++ forums are 100% absurdity...

A la "Urgent help needed! I'm trying to assign void main to char then convert it to a pointer to 2.5D vector but my program do nothing and my compiler said that I have missed semicolon. Why?".

Give me code, pleazzzzzzzzzzzzzz! ;)

Nope this loop doesn't go to infinity...
For positive and negative value of both i and j, it will not even enter the loop...
if either i or j is negative, it will enter the loop once... thats it...

This article has been dead for over six months. Start a new discussion instead.