You are on page 1of 14

K. E.

Society’s
Rajarambapu Institute of Technology, Rajaramnagar

 Diploma

Programming in C (312303) project

Report on
“Prepare a report on develop a simple calculator to perform mathematical
operations”

Submitted By:

Om Latane :-2373051

Amey Mithare :-2373052

Utkarsha Patil :-2373053

Aditya Tarlekar :-2373054

Vishwjeet Patil :-2373055

Of Class Fy Computer Engineering (Diploma) Under

The Guidance of:


Ms.Shradha.S.Shinde

For partial fulfillment of the requirement of

‘ Programming in C ’subject under


MSBTE

Department of Computer Engineering (Diploma) 2023-24


DECLARATION
We, the undersigned, hereby declare that the project entitled. A study on
“Prepare a report on develop a simple calculator to perform mathematical
operations” is written and submitted by us to K. E. Society’s Rajarambapu
Institute of Technology, Diploma, Rajaramnagar; during Year 2023-24, First
Semester for partial fulfilment of the ‘Micro Project’ requirement of C
programming (312303,)’ subject under Maharashtra State Board of Technical
Education, Mumbai curriculum, under the guidance of ‘Ms.Shradha.S.Shinde is
our original work.
The empirical findings in this project are based on the data collected in this
project is not copied from any other sources.

Name:- Sign:-

Om Latane :-2373051

Amey MIthare :-2373052

Utkarsha Patil :-2373053

Aditya Tarlekar :-2373054

Vishwjeet Patil :-2373055


K. E. Society’s

Rajarambapu Institute of Technology, Rajaramnagar

Diploma

Certificate
This is to certify that the micro-project report entitled “Prepare a report on
develop a simple calculator to perform mathematical operations” submitted by following
students of class FY Computer Engineering (Diploma) for partial fulfilment of the
requirement of ‘ Programming in C (312303)’course under Maharashtra State Board of
Technical Education, Mumbai curriculum, for the year 2023-24, First Semester in the record
of their own work carried out under my direct supervision and guidance.

Om Latane :-2373051

Amey MIthare :-2373052

Utkarsha Patil :-2373053

Aditya Tarlekar :-2373054

Vishwjeet Patil :-2373055

Ms.Shradha.S.Shinde Mrs. A.M. Jagtap Dr. H. S. Jadhav

( Guide ) (HOD CS&H-Diploma) (Dean Diploma)


ACKNOWLEDGEMENT

It gives us immense pleasure to present our project report on “Prepare a


report on develop a simple calculator to perform mathematical operations”
under the guidance enables this task to path of completion.
We would like to extend our thanks to Prof. Mrs. A.M. Jagtap (HOD),
Ms.Shradha.S.Shinde and all our professors, staff members and all our friends
who extended their co operation to complete.
Finally, yet importantly, we express our gratitude to our RIT Office,
Department, Computer Center and library staff and those who have helped us
directly or indirectly during preparation of this project report.

With warm regards,

Yours Sincerely,

Om Latane :-2373051

Amey MIthare :-2373052

Utkarsha Patil :-2373053

Aditya Tarlekar :-2373054

Vishwjeet Patil :-2373055


Index

Particulars Page
Sr No . No.
1 Title Page 1

2 Introduction 2

3 Basic’s of calculator software 3-4

4 Program Code 5-6

5 Output 6-7

6 Testing and debugging 8

7 Applications of program 9

8 Conclusion 10

9 References 11

Introduction
Creating a calculator using C programming requires understanding of
mathematical operations and user interface. It involves designing a
program for efficient arithmetic operations and user-friendly
interactivity.
In the C of programming, calculators serve as indispensable tools for
performing mathematical calculations efficiently. Building your own
calculator program not only enhances your understanding of
fundamental programming concepts but also provides you with a
practical application to solve mathematical problems.
In this article, we will explore the process of creating a calculator
program in the C programming language. We will take you through
the step-by-step development of a calculator that can perform basic
arithmetic operations, including addition, subtraction, multiplication,
and division. Additionally, we will expand the functionality by
incorporating more advanced operations, such as exponentiation and
square root calculations.
Throughout the article, we will provide clear explanations and code
examples, making it accessible for both beginners and experienced
programmers. By following along, you will gain a deeper
understanding of core programming concepts, such as user input,
control flow, and function implementation.

Basic’s of calculator software :-

Basic Arithmetic Operations


 Addition
Implementing the addition functionality to ensure accurate and
efficient calculations.

 Subtraction
Enabling users to perform subtraction with precision and error
handling.

 Multiplication
Designing a reliable method for multiplying numbers while
considering memory optimization.

 Division
Creating a division feature with error handling for edge cases such as
zero division.
In this program, four separate functions (add, subtract, multiply, and
divide) are defined to perform the corresponding arithmetic
operations. The main function prompts the user to enter an operator
(+, -, *, or /) and two numbers. The switch case statement is then used
to determine the chosen operator and call the appropriate function.
The result of the calculation is stored in the result variable and
displayed on the screen. The program handles invalid operators
gracefully and terminates execution if an error occurs during division
by zero.
Implementing User Input and Output
 User Input :-
Adding functionality for users to input numbers and select arithmetic
operations.
 User Output :-

Displaying the calculation results in a clear and user-friendly manner.

Memory Management and Optimization


 Efficient Memory Usage :-
Optimizing memory allocation to ensure efficient usage and avoid
memory leaks.
 Code Optimization :-

Reviewing and refining the code for optimal performance and

resource utilization.

Testing and Debugging the Calculator Program

 Unit Testing :-
Conducting rigorous tests to ensure the correctness of each arithmetic
operation.

 Debugging :-

Identifying and resolving logical and runtime errors systematically.

 User Testing :-
Gathering feedback through user testing for the calculator’s ease of
use and accuracy.
 Program code :-
#include <stdio.h>

#include <conio.h>

float calculate(float num1, float num2, char opt);

void main()

{ char opt;

floatnum1, num2;

float result;

do {

printf(“Choose an operator (+, -, *, /) to perform an operation in

C calculator:\n”);

scanf(“ %s”, &opt);

printf(“Enter the first number: “);

scanf(“%f”, &num1);

printf(“Enter the second number: “);

scanf(“%f”, &num2);

result = calculate(num1, num2, opt);

printf(“Result: %.2f\n”, result);

printf(“Do you want to perform another calculation? (Y/n): “);

scanf(“ %s”, &opt);

while (opt == ‘Y’ || opt == ‘y’);


printf(“Calculator program ended.\n”); getch(); }

float calculate(float num1, float num2, char opt)

{ float result; switch (opt) { case ‘+’:

result = num1 + num2;

break; case ‘-‘:

result = num1 – num2;

break;

case ‘*’:

result= num1 *

num2;

break;

case ‘/’:

if (num2 == 0)

{ printf(“\nDivisor cannot be zero\

n”);

return 0; }

result = (float)num1 /num2;

break;

default:

printf(“You entered a wrong

operator\n”); return 0; }

return result;

}
Output:-
Applications of simple calculator

Simple calculator with basic arithmetic operations such as


addition, subtraction, multiplication, and division can be used
in various .

Basic Math: Performing simple arithmetic calculations like


adding up grocery expenses, subtracting discounts,
multiplying recipe ingredients, or dividing portions.everyday
situations:

Educational Purposes: Helping students learn and practice


basic math operations, especially at the elementary or middle
school level.

Programming Practice: Implementing a simple calculator


can be a good exercise for beginners learning programming
languages.

Budgeting: Quick calculations for personal finance


management, such as tracking expenses, budget planning, and
calculating savings goals.
Conclusion and Next Steps

A simple user interface has been created to demonstrate the


calculator. The interface addresses the problem of allowing
the user to view a (potentially time consuming) calculation as
it proceeds but also giving an answer which can be used or
checked, by outputting signed digits as they are computed and
then converting the result into decimal when some specified
precision is reached.
After completing the calculator program, the next steps
involve documenting the code, distributing the application,
and gathering user feedback for future improvements.
References :-

https://www.scaler.com/topics/calculator-program-in-c/
https://www.upgrad.com/tutorials/software-engineering/c-tutorial/
calculatorprogram-in-c/ https://www.geeksforgeeks.org/arithmetic-
progression/

You might also like