Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

A CLI calculator written in C. It performs basic arithmetic operations like add, subtract, multiply, and divide. It operates in a continuous loop until the user chooses to exit. This calculator does not follow BODMAS rules i.e. operations are performed in the order of input. Visit to run code in browse: https://onlinegdb.com/Oq7Z5K7G0

License

Notifications You must be signed in to change notification settings

krsahil8825/simplecalculator.c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SimpleCalculator.c

A beginner-friendly console-based calculator written in C. It performs basic arithmetic operations like addition, subtraction, multiplication, and division, and operates in a continuous loop until the user chooses to exit. This calculator does not follow BODMAS rules, meaning operations are performed in the order of input.

License: Apache 2.0


Features

  • Simple and interactive CLI calculator
  • Supports:
    • Addition
    • Subtraction
    • Multiplication
    • Division
  • Clear screen after every operation
  • Continuous operations until manually exited
  • Platform-independent screen clearing (Windows/Linux/macOS)
  • Custom user prompts for better guidance

Usage Instructions

  1. Compile the program:
gcc SimpleCalculator.c -o SimpleCalculator.exe
  1. Run the program:
./SimpleCalculator.exe
  1. Follow on-screen prompts:

    • Enter the first number.
    • Choose an operation.
    • Enter the next number.
    • Repeat until you're done.
    • Press 5 to exit the program and display the final result.

Notes

  • The calculator executes operations sequentially; it does not apply precedence rules like BODMAS.
  • Only valid numeric inputs should be provided.
  • In case of invalid operator input, the program prompts the user again.

Code Structure Overview

  • clearScreen() – Clears the console screen depending on the operating system.
  • chooseOperator() – Displays the operator menu.
  • enterNumber() – Prompts user to enter a number.
  • notValidOption() – Displays a message for invalid input and re-prompts.
  • add(), subtract(), multiply(), division() – Functions to perform respective operations.

Example

***** Welcome To SimpleCalculator.c *****

This Calculator not follows the rule of BODMAS <br/>
Developed By Kumar Sahil. GitHub- https://github.com/krsahil8825

----User Instruction----
1. Press '1' for addition
2. Press '2' for subtraction
3. Press '3' for multiplication
4. Press '4' for division
5. Press '5' for exit
-------Let's Start!-------

Enter a number: 10
Enter a operator: 1
Enter a number: 5
Current Result = 15.00
...
Result = 35.00
Created By Kumar Sahil.
GitHub - https://github.com/krsahil8825/SimpleCalculator.c
CopyRight (c) 2025 Kumar Sahil | All Rights Reserved.

Contributing

Contributions and suggestions to improve this project are welcome. Feel free to fork the repository and submit pull requests.


License

This project is licensed under the Apache License 2.0.


Author

Originally created by Kumar Sahil (2025) | All rights reserved.

Read Notice before Using in Your Project Notice

About

A CLI calculator written in C. It performs basic arithmetic operations like add, subtract, multiply, and divide. It operates in a continuous loop until the user chooses to exit. This calculator does not follow BODMAS rules i.e. operations are performed in the order of input. Visit to run code in browse: https://onlinegdb.com/Oq7Z5K7G0

Topics

Resources

License

Stars

Watchers

Forks

Languages