821
views
Loading...
Uploader Comments (AppleProgramming)
see all
All Comments (7)
-
@iBig13 Ya, they really have some work left to do with Xcode 4. The lack of autofill for C has really been getting on my nerves.
Loading...
Is there any advantages of using the switch statement as opposed to the if statement, or is the switch statement pretty much obsolete compared to the if statement?
Arronsyaoran 11 months ago
@Arronsyaoran I would say that for the most part, you would use if-else statements. However, if you are analyzing a very basic case, a switch may be more appropriate. Let's say you want to get the user to type a number for the month, then you could setup a switch that would check for what the number value is and printf according to what number month you enter (so 2 could be "February"). Using the switch in this case, makes it obvious what you are comparing is all of the months.
AppleProgramming 11 months ago
for the 4:44, I still don't understand why it still print key is n. I know that because there'e no "break " after the case p, so the program will continue.But it will print "key is n " only when the case'n' is satisfied. Obviously it's not....
Please let me know .
MrMacaroonable 1 year ago
@MrMacaroonable The break gets us out of the switch. Once it is in the switch it doesn't get out until it reaches the end or the break statement regardless of the actual case.
AppleProgramming 1 year ago