0% found this document useful (0 votes)
10 views25 pages

Group G09

The document outlines a mini project for creating a simple calculator in C programming, detailing its objectives, proposed solutions, and flow of operations. It includes code snippets, block diagrams, and discusses the learning outcomes and applications of the project. The project serves as a foundational exercise in programming concepts and problem-solving skills.

Uploaded by

memesnagar8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views25 pages

Group G09

The document outlines a mini project for creating a simple calculator in C programming, detailing its objectives, proposed solutions, and flow of operations. It includes code snippets, block diagrams, and discusses the learning outcomes and applications of the project. The project serves as a foundational exercise in programming concepts and problem-solving skills.

Uploaded by

memesnagar8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

NUTAN MAHARASHTRA INSTITUTE OF ENGINEERING & TECHNOLOGY, PUNE

Mini Project

Project Title
EMPLEMENTATION OF SIMPLE CALCULATOR IN C PROGRAMMING

Subject – Fundamental Programming Language [ESC-105-COM]

Guide – Mr. Pratham Joshi


Department of First Year Engineering

FIRST YEAR ENGINEERING - 1st SEM A.Y 2024-25


SUBJECT : FUNDAMENTAL PROGRAMMING LANGUAGE [ ESE-105-COM ]

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

● To create a simple calculator in C that performs basic arithmetic


operations using a switch-case statement

● 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:

1.Input: Accepts two operands and an operator from the


user.

2.Process:

a.Decision Structure: Uses a switch or if-else statement


to determine which arithmetic operation to perform
based on the operator.

b.Arithmetic Operations: Executes addition,


subtraction, multiplication, or division.

3.Output: Displays the result of the operation.

This structure allows for clear flow from input to


processing and finally output, ensuring effective c
8
Flow of Operation

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.

c.Finally, the Output Block presents the result to the user.

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

//C program to make simple calculator using


//switch-case statements

#include <stdio.h> // header file

void main() //main function

{
// define variable
double a,b,add,sub,mul,div ;
// define variable
char operator ;

// Read the operator


printf("\nEnter an operator =");
scanf("%c", & 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);
}

//Define all four operations in the corresponding


// switch case
switch ( operator )

{
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 ;

default : printf("Error! Incorrect operator value \n");


}
}

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:

* A simple calculator program is a great starting point for learning C programming.


* It can be extended to create more sophisticated calculators with advanced features.
* It serves as a foundation for understanding more complex programming concepts and algorithms.
By creating a simple calculator, you gain practical experience in C programming, problem-solving, and
software development

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:

Core 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.

Software Development Skills:


* Code Organization: Structuring the code in a clear and readable manner, using meaningful variable
names and comments.
* Testing and Debugging: Writing test cases to verify the correctness of the code and using debugging
tools to identify and fix errors.
* Code Efficiency: Optimizing the code for performance and resource usage.
By mastering these concepts, you'll be well-prepared to tackle more complex programming challenges and
build more sophisticated applications.
22
References
1. "Let Us C" by Yashavant Kanetkar
This book includes examples and exercises on basic and advanced C programming concepts that can
be applied to building a calculator.
2. "Programming in ANSI C" by E. Balagurusamy
Covers foundational programming logic, operators, and control structures required for calculator
functionality.
3. "C Projects" by Kanetkar Yashavant
A project-based book that includes practical examples and projects like calculators to strengthen
programming skills.
4. "C Programming: A Modern Approach" by K.N. King
This book covers advanced programming concepts and includes exercises to practice implementing
real-world applications, such as a calculator.
5. "Problem Solving and Program Design in C" by Jeri R. Hanly and Elliot B. Koffman
Focuses on problem-solving techniques and project design, helpful for designing a robust calculator
application.

23
CONCLUSION

24
THANK YOU

25

You might also like