Basic calculator with C ++

in #steempress6 years ago (edited)


Source

♦C++♦

Welcome everyone, today we will continue learning to use the C ++ language, for this occasion I want to show you how you can make a simple calculator in a very easy way.

Now the first thing that we will need to carry out our programs is a development environment where we can program, for that I recommend that you download the Dev C ++ applicationhere which facilitates the editing of the code although you can use other programs such as codeblocks, everything depends on which one you feel most comfortable with. Download and install the Dev C ++ we proceed to open it, if you do not want to download and use any program you can do it from an online c ++ editor here

Once we are in the code editor we start to create our document, if you downloaded the application and do not know how to create a document you can visualize it through the first chapter of this tutorial here.


return.jpg

To begin we put first the structure of our code how we can visualize in the following image

#include < iostream >

using namespace std;

int main () {

return 0; }

We proceed to place the variables to be used:

float suma, a, b, resta, multiplicacion, division;

variables.jpg

Then using cout<<" "; we proceed to ask the user the figures that we will need for the operations, it is also used to show or print on the screen the result obtained in the operations.
cin>> ; we use it to store the data that the user is placing.

cin y cout.jpg

Now we can do each of the operations of addition, subtraction, multiplication, division as we can see in the following image:

operaciones.jpg

To finish our small simple calculator, we show the results on the screen as well using thecout<<""; but in the following way:

resultados.jpg

cout<<"The result of your operation is:"<<endl
cout<<"Suma: "<<suma<<endl<<"Resta: "<<resta<<endl<<"Multiplicacion: "<<multiplicacion<<endl<<"Division: "<<division;

We can see that to show the result only it is not necessary to use " " and to make a line break we use
<<endl

final.jpg

Here we visualize the result of our operations.

This has been all, I hope that it has been to your liking, I will be doing more C ++ tutorials explaining them in the simplest way so that we all learn a bit of programming.

separadore ojos.png

follow me on my social networks

twitter.jpg facebook.jpg instagram-logo-gif-9.jpg


All the images are screenshots taken from my pc.
This tutorial was made under the Windows 10 operating system, you can do it with the operating system of your choice.


Posted from my blog with SteemPress : https://erick777.timeets.com/2018/08/27/basic-calculator-with-c/

Sort:  

Nice tutorial. I was looking for a GUI window to do the calculations but it does all of them in the command line. That is basic.

You are the second one I have seen today that uses some RSS to duplicate your blog here on Steemit. This is a huge thing to bring more content here. I am reading up on steempress now.

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by erick777 from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 62892.68
ETH 2581.23
USDT 1.00
SBD 2.73