C Language Calculator Project Report
Student Name: [Your Name]
Course: B.Tech / Diploma / C Programming
Duration: 4 Weeks
1. Introduction
The project aims to develop a simple calculator using C programming. The calculator performs basic
arithmetic operations such as addition, subtraction, multiplication, and division. This project helps
students understand programming fundamentals and logic building.
2. Objective
- To understand the use of C language constructs like loops, conditional statements, and functions.
- To implement a console-based calculator application.
- To improve problem-solving and debugging skills.
3. Problem Definition
Design a program that can accept two numbers from the user and perform basic arithmetic
operations. The program should display the result and allow the user to perform multiple calculations
until they choose to exit.
4. Algorithm / Flowchart
1. Start
2. Display menu for operations: Add, Subtract, Multiply, Divide, Exit
3. Accept user choice
4. Accept two numbers from the user
5. Perform selected operation
6. Display result
7. Ask if the user wants to continue
8. If yes, go to step 2; else, end
5. C Program Code
#include <stdio.h>
int main() {
int choice;
float num1, num2, result;
do {
printf("\nCalculator Menu:\n");
printf("1. Addition\n2. Subtraction\n3. Multiplication\n4. Division\n5. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
if(choice >=1 && choice <=4){
printf("Enter first number: ");
scanf("%f", &num1);
printf("Enter second number: ");
scanf("%f", &num2);
}
switch(choice){
case 1: result = num1 + num2;
printf("Result: %.2f\n", result);
break;
case 2: result = num1 - num2;
printf("Result: %.2f\n", result);
break;
case 3: result = num1 * num2;
printf("Result: %.2f\n", result);
break;
case 4: if(num2 != 0){
result = num1 / num2;
printf("Result: %.2f\n", result);
} else {
printf("Error: Division by zero!\n");
}
break;
case 5: printf("Exiting calculator.\n");
break;
default: printf("Invalid choice!\n");
}
} while(choice != 5);
return 0;
}
6. Sample Input/Output
Calculator Menu:
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Exit
Enter your choice: 1
Enter first number: 10
Enter second number: 5
Result: 15.00
7. Conclusion
This project demonstrates the use of basic C programming constructs to develop a functional
calculator. It enhances logical thinking and provides practical experience in writing, testing, and
debugging C programs.
Prepared By: [Your Name]
Date: [Date]