C Switch

About if

  • Instead of writing many if..else statements, you can use the switch statement.

(অনেক if..else স্টেটমেন্ট লেখার পরিবর্তে, আপনি সুইচ স্টেটমেন্ট ব্যবহার করতে পারেন।)

Syntax:

Example :

Output:

Note: switch(expression). There expression we can take form user by using scanf()

WAP to input two numbers and an operator and calculate the result according to the following conditions:

Operator

‘+’

‘-‘

‘*’

‘/’

‘%’

Result

Add

Subtract

Multiply

Divide

Remainder