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 value-র 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.