+ 2
C if else and switch
Please anyone tell me when use if else and when use switch I am quite not sure@_@
2 Réponses
+ 6
A switch statement is usually more efficient than a set of nested ifs. Check the Testing Expression: An if-then-else statement can test expressions based on ranges of values or conditions, whereas a switch statement tests expressions based only on a single integer, enumerated value, or String object. ...
https://www.google.com/url?sa=t&source=web&rct=j&url=https://www.geeksforgeeks.org/switch-vs-else/amp/&ved=2ahUKEwjonr7Xh4fsAhVqyDgGHWFHCcMQFjABegQIChAH&usg=AOvVaw39SVgVE9vBOf9W_tBqYxUl&cf=1
you can also learn in detail by visit here⬆️
+ 3
Hye Shirt
So see that Switch statement in C tests the value of a variable and compares it with multiple cases. Once the case match is found, a block of statements associated with that particular case is executed.
I hope this will help you better..
If you wanna know properly then do ping me I'll surely give you..
Hope this helps ✌️