Lesson 9 of 34

switch: ಹಲವು values ನಿಂದ ಆಯ್ಕೆ

8 min 30 XP

switch ಒಂದು value ಆಧರಿಸಿ ಹಲವು ಮಾರ್ಗಗಳಲ್ಲಿ ಒಂದನ್ನು ಆರಿಸುತ್ತದೆ. ಪ್ರತಿ case ಕೊನೆಯಲ್ಲಿ break ಬೇಕು, ಇಲ್ಲದಿದ್ದರೆ ಮುಂದಿನ case ಕೂಡ ಓಡುತ್ತದೆ (fall-through). ಏನೂ ಹೊಂದದಿದ್ದರೆ default ಓಡುತ್ತದೆ.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

switch String ಮತ್ತು char values ಜೊತೆಗೂ ಕೆಲಸ ಮಾಡುತ್ತದೆ. ಇಲ್ಲಿದೆ ಒಂದು ಚಿಕ್ಕ calculator.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

Challenge

+30 XP

ಎರಡು ಸಂಖ್ಯೆಗಳು ಮತ್ತು ಒಂದು operator (+ - * /) ಓದಿ ಫಲಿತಾಂಶ print ಮಾಡಿ. ಬೇರೆ ಯಾವುದೇ operator ಗೆ "Invalid" print ಮಾಡಿ. Input: 8 * 5 → Output: 40

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.