0% found this document useful (0 votes)
45 views4 pages

Calculator Microproject Final Report

The document outlines a micro project report for developing a simple calculator in C that performs basic arithmetic operations. It includes objectives, problem definition, an algorithm for implementation, testing and debugging strategies, and the source code. The project aims to enhance understanding of programming concepts while providing a user-friendly experience.
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)
45 views4 pages

Calculator Microproject Final Report

The document outlines a micro project report for developing a simple calculator in C that performs basic arithmetic operations. It includes objectives, problem definition, an algorithm for implementation, testing and debugging strategies, and the source code. The project aims to enhance understanding of programming concepts while providing a user-friendly experience.
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/ 4

Government Polytechnic Ahemadnagar

Academic Year: 2024-25

Micro Project Report

Title: SIMPLE CALCULATOR IN C

1. Introduction
A calculator is an essential tool in mathematics, science, and daily life. This microproject aims to

develop a simple calculator using C that can perform basic arithmetic operations such as addition,

subtraction, multiplication, and division. The project helps in understanding loops, switch-case

statements, and user input handling. By implementing a menu-driven system, users can interact

dynamically with the program. This project serves as a foundation for learning programming and can

be extended into more advanced applications like scientific calculators or financial tools.

2. Objectives
- Develop a menu-driven calculator in C.

- Allow users to perform arithmetic operations interactively.

- Implement proper error handling, preventing invalid inputs.

- Ensure continuous execution without restarting the program.

- Enhance understanding of switch-case, loops, and functions in C programming.

3. Problem Definition
A simple command-line calculator is needed to perform arithmetic operations based on user input.

The calculator should take two numbers, perform the selected operation, and display the result. It

should also handle errors like division by zero and invalid inputs. Continuous execution should be

ensured to allow multiple calculations without restarting. The program should be user-friendly,
providing clear prompts and messages.

4. Algorithm
Step 1: Start

Step 2: Display menu options

Step 3: Take user input for operation choice

Step 4: Input two numbers

Step 5: Perform the selected arithmetic operation

Step 6: Display the result

Step 7: Ask if the user wants to continue

Step 8: Repeat or exit based on user choice

Step 9: End

5. Testing & Debugging


- Test different inputs and verify correct results.

- Ensure division by zero is handled correctly.

- Check how the program handles invalid inputs like characters instead of numbers.

- Verify multiple calculations in a row.

- Debug and fix logical errors, input validation, and precision issues.

6. Conclusion
The calculator microproject successfully implements a simple arithmetic calculator using C. It

demonstrates fundamental programming concepts such as decision-making, loops, functions, and

error handling. The project allows multiple calculations without restarting and provides a

user-friendly experience. This project serves as a strong foundation for learning C programming and

can be extended into more advanced applications like scientific calculators.

7. Source Code

#include <stdio.h>
void calculator() {
int choice;
double num1, num2, result;

do {
printf("\n--- Simple Calculator ---\n");
printf("1. Addition (+)\n");
printf("2. Subtraction (-)\n");
printf("3. Multiplication (*)\n");
printf("4. Division (/)\n");
printf("5. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);

if (choice >= 1 && choice <= 4) {


printf("Enter first number: ");
scanf("%lf", &num1);
printf("Enter second number: ");
scanf("%lf", &num2);
}

switch (choice) {
case 1:
result = num1 + num2;
printf("Result: %.2lf + %.2lf = %.2lf\n", num1, num2, result);
break;
case 2:
result = num1 - num2;
printf("Result: %.2lf - %.2lf = %.2lf\n", num1, num2, result);
break;
case 3:
result = num1 * num2;
printf("Result: %.2lf * %.2lf = %.2lf\n", num1, num2, result);
break;
case 4:
if (num2 != 0) {
result = num1 / num2;
printf("Result: %.2lf / %.2lf = %.2lf\n", num1, num2, result);
} else {
printf("Error: Division by zero!\n");
}
break;
case 5:
printf("Exiting...\n");
break;
default:
printf("Invalid choice!\n");
}
} while (choice != 5);
}

int main() {
calculator();
return 0;
}

8. Expected Output
Example Execution:

--- Simple Calculator ---

1. Addition (+)

2. Subtraction (-)

3. Multiplication (*)

4. Division (/)

5. Exit

Enter your choice: 1

Enter first number: 5

Enter second number: 3

Result: 5.00 + 3.00 = 8.00

Enter your choice: 4

Enter first number: 10

Enter second number: 0

Error: Division by zero!

Enter your choice: 5

Exiting the calculator...

You might also like