commercial calculator in C
18CPL17/27
Program1:-
Develop a program to solve simple computational problems using arithmetic expressions and use of each operator leading to a simulation of a commercial calculator. (No built-in math function).Concept Building
1)What is a Switch statement?
2)How many cases can you have in a switch statement?
3)What does break in switch statement indicate?
4)What is a case in a switch statement?
2)How many cases can you have in a switch statement?
3)What does break in switch statement indicate?
4)What is a case in a switch statement?
What is a Switch statement?
A switch statement tests the value of a variable and compares it with multiple cases. Once the case match is found, a block of statements associated with that particular case is executed.How many cases can you have in a switch statement?
In C language we can have up to 257 cases.What does break in switch statement indicate?
The break statement is used to terminate the switch case.What is a case in a switch statement?
The switch statement allows a variable to be tested for equality against a list of values. Each value called a case, and the variable being switched on is checked for each switch case.Flowchart:-

Algorithm:-
StartStep 1: [Enter first number] read num1
Step 2: [Enter Second number] read num2
Step 3:[Enter Choice] read choice
Step 4:[To perform addition] if the choice is equal to plus add num1 and num2 print result.
Step 5: [To perform subtraction] if the choice is equal to minus subtracts num2 from num1 print result.
Step 6: [To perform multiplication] if the choice is equal to multiplication multiply num1 and num2 print result.
Step 7: [To perform division] if the choice is equal to division divide num1 by num2 print result.
Step 8: [To perform Modulus] if the choice is equal to modulus divide num1 by num2 print result (remainder)
STOP
Code in C:-
***************************************************************************
OUTPUT:
First run:
Enter first number: 10
Enter second number: 20
Enter your choice:
1.Addition
2.Substraction
3.Multiplication
4.Divide
5.Reminder
1
Result: 10 + 20 = 30.000000
Second run:
Enter first number: 10
Enter second number: 3
Enter your choice:
1.Addition
2.Substraction
3.Multiplication
4.Divide
5.Reminder
4
Result: 10 / 3 = 3.333333
Third run:
Enter first number: 10
Enter second number: 3
Enter your choice:
1.Addition
2.Substraction
3.Multiplication
4.Divide
5.Reminder
9
Invalid
******************************************************************************
Video Tutorial:-
Source code Github:- https://github.com/NAJMUS7834/VTUCLAB/edit/master/Calci.c
No comments:
For Query and doubts!