To write a C++ program that adds two numbers we need to write the following code:
We write a line which calls a library that has functions we need:
#include
(Then we create a function that does our sum:)
int main()
(Here we read the two values we need for our sum, called x and y. These can be chosen by the user and written from the keyboard:)
{ cin>>x,y;
(In the next lines we declare a variable called S which stands for sum and then we give it the value of x+y:)
int S;
S= x+y;
(In the end, we return the value of S and close the brackets of the function)
cout<
}