MYTUTOR SUBJECT ANSWERS

237 views

How can we write a C++ program to add two numbers?

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<

}

Cosmin B. A Level Maths tutor, GCSE Maths tutor, GCSE Computing tutor...

11 months ago

Answered by Cosmin, an A Level TBA tutor with MyTutor

Still stuck? Get one-to-one help from a personally interviewed subject specialist

0 SUBJECT SPECIALISTS

About the author

Cosmin B.

Currently unavailable: for regular students

Degree: Computer Science (Bachelors) - University College London University

Subjects offered: TBA, Maths+ 1 more

TBA
Maths
Computing
-Personal Statements-

“I am currently a Computer Science student at University College London. I have always had a passion for science and technology  and I hope that I can share it with everyone else through my tutoring sessions. I am a calm and friendly p...”

You may also like...

Posts by Cosmin

How can we calculate the derivative of function f(x)= (x+2)/(x-1)?

How can we solve a two-equation, two-unknown values?

How can we write a C++ program to add two numbers?

The ratio between the molar mass of an alkene(A) and an alkyne(B) with the same number of carbon atoms is 1.05. Find the molecular formulas of the two hydrocarbons then write the reaction for how we can obtain the alkene A from the alkyne B.

Other A Level TBA questions

How can we write a C++ program to add two numbers?

View A Level TBA tutors

Cookies:

We use cookies to improve our service. By continuing to use this website, we'll assume that you're OK with this. Dismiss

mtw:mercury1:status:ok