Lesson 23 of 24

Exceptions: try, catch మరియు throw

9 min 35 XP

throw తో error ను పెంచి try/catch తో నిర్వహించండి. Standard exceptions లో invalid_argument, out_of_range, runtime_error ఉన్నాయి; తప్పు text కు stoi() invalid_argument ఇస్తుంది.

Example: edit me and press Run

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

Challenge

+35 XP

రెండు text values ఉన్న n లైన్లు చదవండి. వాటిని stoi తో మార్చి integer division ఫలితాన్ని print చేయండి. సంఖ్యలు కాకపోతే "Invalid number", భాజకం సున్నా అయితే "Divide by zero" print చేయండి (దాన్ని మీరే throw చేయండి). Input: 3 20 4 7 0 x 2 Output: 5 Divide by zero Invalid number

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