void main()
{
  int i,j;
  /*input values of i and j*/
  while(i*j<0&&++i!=7&&j++!=9)
  {
    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...

you need to initialize the values of i and j to something.

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

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).

while(i*j<0&&++i!=7&&j++!=9)

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?".

commented: Give me code, pleazzzzzzzzzzzzzz! ;) +10

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...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.