Group G09
Group G09
Mini Project
Project Title
EMPLEMENTATION OF SIMPLE CALCULATOR IN C PROGRAMMING
1. Aslam Sayyad
2. Kunal Rane
3. Nishant Rathod
4. Rahat Quazi
5. Tejas Patil
6. Umeshreddy Waddankeri
2
Problem Statement/objectives
Problem Objectives :
To create a C program that simulates a basic calculator, capable of performing fundamental arithmetic
operations:
* Addition
* Subtraction
* Multiplication
* Division
The program should:
* Prompt the user to enter two numbers (operands).
* Ask the user to input the desired arithmetic operation (+, -, *, /).
* Perform the specified operation on the given numbers.
* Display the calculated result to the user.
* Handle potential errors such as division by zero
3
Proposed solution
● This program prompts the user for an operator and two numbers, then
performs the corresponding arithmetic operation and displays the result.
It also includes error handling for division by zero and invalid operators
4
Flow Chart
5
6
Block Diagram
7
Description of Block Diagram
To create a simple calculator in C, the block diagram
typically includes the following components:
2.Process:
a.The flow starts from the Input Block, where the user provides the required data.
b.The Processing Block processes this data and computes the result based on the chosen operation.
This structure ensures a clear and organized approach to implementing a calculator program in C,
facilitating ease of understanding and coding.
9
CODE OF CALCULATOR
{
// define variable
double a,b,add,sub,mul,div ;
// define variable
char operator ;
10
// condition statement
if(operator == '+' || operator == '-' || operator == ‘/’ || operator == '*')
{
// Read the two number
printf("value of a:");
scanf("%lf",&a);
printf("value of b:");
scanf("%lf",&b);
}
{
case'+' : add = a + b ;
printf("%lf",add);
break ;
11
case'-' : sub = a - b ;
printf("%lf",sub);
break ;
case'*' : mul = a * b ;
printf("%lf",mul);
break ;
case'/' : div = a / b ;
printf("%lf",div);
break ;
12
Results : Experimental Testing of a project
13
14
15
16
17
Innovation or Uniqueness of the solution
18
Applications
Applications of a Simple Calculator in C Language:
While a simple calculator might seem like a basic application, it serves as a fundamental building
block for more complex programs and helps in understanding core programming concepts. Here are
some of its applications:
1. Learning and Practice:
* Basic C concepts: It reinforces understanding of variables, operators, input/output operations, control
flow (like if-else or switch-case), and functions.
* Problem-solving skills: It helps in breaking down a problem into smaller steps, designing an
algorithm, and implementing the solution.
* Debugging and error handling: It provides an opportunity to identify and fix errors, such as division by
zero or invalid input.
2. Building Blocks for Larger Projects:
* Scientific calculators: By incorporating more complex mathematical functions like trigonometric,
logarithmic, and exponential operations.
* Financial calculators: For calculations related to interest rates, loans, investments, etc.
* Engineering tools: For specialized calculations in fields like civil, mechanical, or electrical
engineering.
* Game development: For simple calculations like scoring, timing, or physics simulations. 19
3. Educational Tools:
* Teaching programming: It can be used as a hands-on exercise to introduce programming concepts to
beginners.
* Demonstrating algorithms: It can be used to visualize the execution of algorithms, such as arithmetic
operations or logical expressions.
4. Embedded Systems:
* Microcontrollers: Simple calculators can be implemented on microcontrollers to perform basic
calculations for control systems.
Key Takeaways:
20
Learning Outcome from a Project
Learning Outcomes from a Simple Calculator in C
By building a simple calculator in C, you can gain a solid foundation in several fundamental
programming concepts:
* Variables and Data Types: Understanding how to declare and initialize variables to store
numbers, characters, and other data types.
* Input/Output Operations: Learning to use scanf and printf functions to take input from the
user and display output on the console.
* Arithmetic Operators: Mastering the use of +, -, *, and / operators to perform basic
arithmetic operations
* Conditional Statements: Using if-else statements to make decisions based on specific
conditions, such as checking for division by zero
21
* Switch Statements: Employing switch-case statements to efficiently handle multiple choices for the
arithmetic operation.
* Operator Precedence and Associativity: Understanding the order in which operations are performed
and how to use parentheses to control the evaluation order.
Problem-Solving and Algorithmic Thinking:
* Problem Decomposition: Breaking down the problem of building a calculator into smaller, manageable
steps.
* Algorithm Design: Developing a step-by-step plan to solve the problem, including input, processing, and
output.
* Error Handling: Implementing error checking and handling mechanisms, such as checking for division by
zero.
23
CONCLUSION
24
THANK YOU
25