A program that adds 2 Numbers C++ (Microsoft Visual Studio)

Hello! A few days ago I started to practice programming, I chose the C ++ language, and my IDE (Code Editor) is Visual Studio, I'm starting from the basics, so today I'll show you how I did a program that executed the sum of 2 numbers.

To do this program I used the C ++ (iostream) libraries (stdlib) and (math.h) and the (using namespace std) to facilitate the writing of the code in this way it will not be necessary to place (std: :) to separate the text ; The first two are data input and output standards, and (math.h) is a special library containing parameters for performing advanced mathematical operations; I decided to include it since the user can have the freedom to enter negative and positive numbers, decimals or integers.

The variables we use will be float (floating value) this will allow the values ​​to be integer, decimal and negative (unlike we use int) that only allows whole numbers.

We know that we need 2 numbers to make a sum, which we will ask the user and store their value in 2 respective variables, once we have those 2 values ​​that we do not know, however we know they are in A and B, we can add them to obtain a Result C.

Once this is established (C = A + B), when we show the user (C) will not see the letter if not the result of the operation that is raised in variable (C). And this is the sum of the 2 numbers I entered earlier.

The complete code would look like this ...
sasasas.PNG

We proceed to Compile and verify that the execution is correct ...ejecuacuion uma.PNG

As you can see I entered negative and positive decimal values, and I threw a correct result of that operation, this by the use of the library (math.h) without the use of this library automatically the negative value that we write will happen to positive, since The negative numbers are Imaginary. And do not exist in natural, whole numbers.

That was all for today, I will be uploading more blogs about programming, thanks for reading me if you have any suggestions or criticism, leave it in the comments do not forget to support with your UpVote. Regards...

Sort:  

Enjoy! I remember doing C++ at varsity still. Brings back good memories. :D
Ask if you need help... I'm happy to help if you get stuck.

good luck with that! :)
Upvotng and folowing :)

ty, i following you.

Coin Marketplace

STEEM 0.18
TRX 0.15
JST 0.029
BTC 62260.20
ETH 2431.98
USDT 1.00
SBD 2.64