Project Simple Calculator
Project Simple Calculator
On
Simple Calculator
Submitted in partial fulfillment of the requirement of
Project – I
Of
Bachelor of Information Technology
Submitted to
Purbanchal University
Biratnagar, Nepal
Submitted By
1
CONTENTS
1. Introduction 3
2. Algorithm 4
3. Flowchart 5
4. Coding 7
5. Conclusion 12
6. Features Recommendation 13
7. Reference 14
2
Chapter 1 : INTRODUCTION
3
Chapter 2:- Algorithm
An algorithm is a set of commands that must be followed for
a computer to perform calculations or other problem-solving
operations.According to its formal definition, an algorithm is a finite
set of instructions carried out in a specific order to perform a
particular task. It is not the entire program or code; it is simple logic
to a problem represented as an informal description in the form of a
flowchart or pseudocode.
Features:-
1. Finiteness, means it must always terminate after a finite number of
steps.
2. Definiteness, means each step must be precisely defined and clear.
3. Input, means it has zero or more inputs, i.e., an algorithm can run
without taking any input.
4. Output, means it has one or more outputs, i.e., an algorithm must
produce atleast one output.
5. Effectiveness, means it is also generally expected to be effective.
Advantages:-
1.It is a step-wise representation of a solution to a given problem, which
makes it easy to understand.
2. An algorithm uses a definite procedure.
3. It is not dependent on any programming language, so it is easy to
understand for anyone even without programming knowledge.
4. Every step in an algorithm has its own logical sequence so it is easy
to debug.
5. By using algorithm, the problem is broken down into smaller pieces
or steps hence, it is easier for programmer to convert it into an actual program.
Disdvantages
1. Alogorithms is Time consuming.
2. Difficult to show Branching and Looping in Algorithms.
3. Big tasks are difficult to put in Algorithms.
Examples:-
Step 1:- Start
Step 2:- Enter two numbers a & b
Step 3:- Sum two numbers (Sum=a+b)
Step 4:- Print results
Step 5 :- End
4
Chapter 3 :- FLOWCHART
Flowchart:-
A flowchart is a type of diagram that represents a workflow or
process. A flowchart can also be defined as a diagrammatic
representation of an algorithm, a step-by-step approach to solving a
task.
Symbols:-
5
Advantages:-
1. Effective Communication: Flowcharts are better way of
communicating the logic of the system.
2. Easy Debugging and Efficient Testing: The Flowchart helps in
debugging and testing process.
3. Efficient Coding: The flowcharts development phase are very useful
during development.
Disadvantage:-
1. Complex Logic: For complicated logic, flowchart becomes complex and
clumsy.
2. Difficulty in Modifications: If change is required in the logic then
flowchart needs to be redrawn and requires a lot of time.
6
Chapter 4 :- CODING
Program to Create a Simple Calculator Using if-else Statement
// Subtraction
result = num1 - num2;
}
else if (op == '*') {
// Multiplication
result = num1 * num2;
}
else if (op == '/') {
// Division
// Check for division by zero
if (num2 != 0) {
result = num1 / num2;
}
else {
printf("Error! Division by zero.\n");
return INT_MIN;
7
}
}
else {
printf("Error! Operator is not correct.\n");
return INT_MIN;
}
return result;
}
int main() {
char op;
double num1, num2;
return 0;
}
8
Simple Calculator Program using switch Statement
// Addition
result = num1 + num2;
break;
case '-':
// Subtraction
result = num1 - num2;
break;
case '*':
// Multiplication
result = num1 * num2;
break;
case '/':
// Division
9
// Check for division by zero
if (num2 != 0) {
result = num1 / num2;
}
else {
printf("Error! Division by zero.\n");
return -1;
}
break;
default:
printf("Error! Operator is not correct.\n");
return -1;
}
}
int main()
{
char op;
double num1, num2, result;
10
return 0;
}
11
Chapter 5 :- CONCLUSION
Key Features
12
Chapter 6:- FEATURES RECOMMENDATION
While this project provides a solid foundation, there are opportunities for future
improvements:
13
Chapter 7:- REFRENCE
Special Thanks to :-
1. Gemini AI :- https://gemini.google.com/app/
2. Co- pilot :- https://copilot.microsoft.com/
3. Geeksforgeeks:- https://www.geeksforgeeks.org/
14