How to make a simple calculator in c++

 

In this tutorial you learn how to program a simple calculator in c++ . Like given video. In this video you can understand how it works & it's functionalities:


To making Like above given calculator follow given steps:
1) Make a file in any c++ program code editor( ex. calculator.cpp)
2) write code:

Describing some line:

#include<conio.h>, system("cls"), getch():
 Is used for showing options or start program for a certain stage. Like: Options, and collect choice.


Discuss code or program:
1) In main function we run a while loop for continuously run the program.
2) under the  parenthesis give value 1 .
3) And it's curly round bracket we write system("cls").
4) Give some options when program run Like:
1) Enter 1 for +
2) Enter 2 for -
3) Enter 3 for *
4) Enter 4 for /
5) Enter 5 for exit.
Defining variable, function, stop program option:
i) Collect user choice in ch variable.
ii) On his choice compare in if condition for run further task or quite program.
iii) When user not selected option 5 than provide prompt for collecting 1st and 2nd value for calculating.

iv) On user choice switch case match value from given options which 1 to 5 number. 
v) Than calculate behalf of operator vi) And store result value in variable c.
vii) And print it in equation format.
vii) For other calculation no need to close program.Simply Enter any key and program start from choice option stage.Or when user select option number 5 the program get quite.

Conclusion:
In this tutorial we understand how to program simple calculator in c++. And discuss it's functionalities like collection of user operator calculating values for calculation.
Or quite option.
My tutorial readers if you already make this type of program than you can write your "program instructions which give a user to program" in comment section. If not then write how do you like it.
 





Comments

Popular posts from this blog

design a layout of MCQ test and functionality using HTML, CSS, JAVASCRIPT

important ideas in child development