Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Creating and Running Basic Addition, Subtraction, Multiplication, and

Division Programs Using Microsoft Visual Studio


These instructions should help you to create basic mathematical programs involving addition,
subtraction, multiplication and division using Microsofts Visual Studio software.

Creating Your Programming Workplace


1. Open up the Microsoft Visual Studio program.
2. Click the File option in the top left corner of the screen once the program opens.
Afterwards hover over the New option and then click Project.

3. This will bring up a new window that has all of the various applications that you can
open. In this menu, click on Visual C++ option on the left. This will bring up a list of
options in the center of the menu.

4. Click the Empty Project option, and then click OK in the bottom right of the window.

5. This should create your project. From here, there should be four folders on the right hand
corner of the screen. Right click the Source Files folder, hover over the Add option, and
then select New Item.

6. A new window should open. Select the C++ File (.cpp) option and then click the Add
button on the lower right hand side of the window. Youre ready to begin programming.

Creating Your Programs


1. A .cpp file will open in your program. Click inside of the file and type out
#include <iostream>
2. Press the enter key on your keyboard and type out using namespace std;
3. Press the enter key two times and type out int main ( )

4. Press the enter key once more and type a { character. Afterwards, hit the enter key again.

5. You are now ready to initialize any variables that you will use in your computations. To
do this, type out int and then the name of the variable followed by a semicolon,
pressing the enter key afterwards. For example, int x;
6. Repeat this process until you have initialized all of the variables that you will need for
your computations.
7. Next, youll need to assign each variable a numerical value. So, for each variable click
between the name and the semicolon and type = followed by whatever number that the
variable is. For example, int x = 50;
8. Now youre ready to do your computations. Well start with addition. Type cout <<
followed by each of your variables, each separated by a + sign, and a semicolon at the
end. For example, cout << x + y + z;
9. Press the enter key and then type out Return 0;

10. Press the enter key once more and type a } character.

11. You have completed your program, now you must run it. To do this we must first debug
the program. This is done simply by clicking the green triangle with Local Windows
Debugger to the right side of it on the taskbar at the top of the screen.

12. Once you are finished debugging, a window should pop up with the numerical answer to
your computation.
13. For Subtraction, the[ process is nearly identical, just replace all instances of the + sign
with a sign.
14. For Multiplication, simply replace all instances of the + or signs with a * sign.
15. Finally, for division, substitute all instances of int inside the { and } brackets with float.
16. After you have done this, simply replace all instances of either a +, -, or * sign with a /
sign.

You might also like