Greetings all...
X-)
As I am a half-newbi I still do know how conditions work in a normal loop, or do I? (I have the feeling something is wrong, either with me today, or my compiler; which by the way is Borland C++ Builder 5)
This is the thing that confuses me, asuming we have initialized x and y
Doesn't this "code-snip" say that: As long as BOTH x AND y DO NOT have the value 0(zero), it will enter the loop and run the sequenze?(cause the statement is false?) Well, when I execute the program and enter x=1 and y=0, then the program will no longer enter the loop.
I could of course be wrong cause the program I wrote wanted me to use this:
I know for certain that as long as the conditions within a loop are true, it will not be entered(or have I got it mixed up).
do{
x=4
}while(x!=1); // this program will run forever
but
do{
x=4
i=1
}while(x!=1 && i!=1); // this will only run once
whilst
do{
x=4
i=1
}while(x!=1 || i!=1); // this will run forever
Can someone explain to a confused boy, how this can be?
NEED answers, desperate(my head is spinning s-))!!
Thanks for anything you can come up with My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
X-)
As I am a half-newbi I still do know how conditions work in a normal loop, or do I? (I have the feeling something is wrong, either with me today, or my compiler; which by the way is Borland C++ Builder 5)
This is the thing that confuses me, asuming we have initialized x and y
Code:
do
{
scanf("%d",&x);
scanf("%d",&y);
} while( x!=0 && y!=0 );
Doesn't this "code-snip" say that: As long as BOTH x AND y DO NOT have the value 0(zero), it will enter the loop and run the sequenze?(cause the statement is false?) Well, when I execute the program and enter x=1 and y=0, then the program will no longer enter the loop.
I could of course be wrong cause the program I wrote wanted me to use this:
Code:
do
{
scanf("%d",&x);
scanf("%d",&y);
} while( x!=0 || y!=0 );
I know for certain that as long as the conditions within a loop are true, it will not be entered(or have I got it mixed up).
do{
x=4
}while(x!=1); // this program will run forever
but
do{
x=4
i=1
}while(x!=1 && i!=1); // this will only run once
whilst
do{
x=4
i=1
}while(x!=1 || i!=1); // this will run forever
Can someone explain to a confused boy, how this can be?
NEED answers, desperate(my head is spinning s-))!!
Thanks for anything you can come up with My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work