Exercise 2: Implementing Calculator
Let's implement a calculator by using Switch statements
We'll cover the following
Problem statement
Write a code that will take the following:
Two
float
type variables namednum1
andnum2
a
char
type variable calledOperator
. TheOperator
variable can be passed the following:+
,-
,*
and/
Use
switch
statements to compute the following on thenum1
andnum2
variables.addition
subtraction
multiplication
division
Sample input
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy