+ 1
Another problem
int a,b,c,d, e=11; a=b=c=d=0; do{ e = e+1; a = a+1; if(a>=2) b = b+1; if(b>=2) c = c+1; if(c>=2) d = d+1; if((a&&b)&&(c&&d)){ printf(" %d",e);break; } }while(1); //end didn't understand the last if statement, if anyone can please explain.
5 Respostas
+ 17
logical & operator returns true for any values other than 0
for eg.:-
1&&0 = 0 (false)
0&&0 = 0 (false)
1&&1 = 1 ( true)
2&&3 = 1 (true)
5&&7 = 1 (true)
n1&&n2 = 1 (true) ; where. n1,n2 ≠ 0
https://www.sololearn.com/learn/CPlusPlus/1619/?ref=app
+ 16
yes sorry it will output 15
1st time the condition of last if will be false then 2nd time it will be true
it will break after printing 15
did u got the idea about last if statement
+ 15
a = 0 + 1 = 1
b = c = d = 0
since all if has false condition
therefore in last if
if ((1&&0)&&(0&&0)) {
printf("something");
break; }
condition false
nothing happens...
because of while(1)
results in infinite loop
+ 1
this outputs 15. not infinite loop
+ 1
sorry i don't understand how if(1&&0) works. can you please explain?