0
If loop and array in C++
Can I use if loops in arrays like this:- string test="Yes"; string test1="No"; if(test=test1){ cout<<test; } else{ cout<<test1; }
5 odpowiedzi
+ 11
Your code will give error but in if condition u cannot assign value .
+ 2
A if-condition / -branch is never any kind of a loop. This piece of code can be used within a loop. And please note, that your if-condition will always remain true and your else-branch is dead code.
+ 2
That's interesting 🤔
Tested with android app, Samsung browser in mobile mode, Samsung browser in desktop mode, Chrome: I see 6 messages, 3 from you, 2 from me, 1 from Sandra Meyer
+ 1
In original code, as Sandra Meyer pointed out, else-branch is dead code.
In code corrected by Martin Taylor, if-branch is dead code.
What are you trying to do?
+ 1
Martin Taylor Are you joking? She gave the first answer, 15 hours ago