LAB # 02: Basic Arithmetic using C++
Lab Objective:
The main objective of this lab is to introduce students to the fundamentals of basic arithmetic
operations in C++. Students will learn how to perform basic arithmetic operations such as
addition, subtraction, multiplication, and division using C++ programming. By the end of the
lab, students will gain practical experience in using variables, operators, and control structures to
implement simple arithmetic calculations.
Hardware/Software Tools:
Hardware: Desktop/Computer
Software Tool: MS Visual Studio 2013
Lab Description:
This lab focuses on implementing basic arithmetic operations in C++ programming. The students
will start by understanding the role of data types and variables to store numerical values and use
appropriate operators to perform basic arithmetic tasks. The lab will cover various arithmetic
operators such as addition (+), subtraction (-), multiplication (*), and division (/). Finally, the
students will use input/output functions to display the results clearly and in a user-friendly
format, reinforcing their skills in coding and debugging C++ programs.
Arithmetic Operators:
Arithmetic operations are performed using operators that allow you to manipulate numbers in
various ways. These operations include addition, subtraction, multiplication, and division. When
writing a program, you can use the arithmetic operators +, -, *, and / to carry out these
calculations. For example, the addition operator + adds two numbers together, the subtraction
operator - subtracts one number from another, the multiplication operator * multiplies two
numbers, and the division operator / divides one number by another.
Command Name Example Output
+ Addition 4+5 9
- Subtraction 8-5 3
* Multiplication 4*5 20
/ Division 19/3 6
% Remainder 19%3 5
1
, 1. Addition (+): The addition operator is used to add two values together. For example:
This example/code defines two integer variables, a and b, with values 5 and 3,
respectively. It then adds them together, stores the result in the variable result, and
displays the sum to the console.
2. Subtraction (-): The subtraction operator is used to subtract one value from another. For
example:
This code/example defines two integer variables, a and b, with values 5 and 3,
respectively. It then subtracts b from a, stores the result in the variable result, and
displays the difference to the console.
2
Lab Objective:
The main objective of this lab is to introduce students to the fundamentals of basic arithmetic
operations in C++. Students will learn how to perform basic arithmetic operations such as
addition, subtraction, multiplication, and division using C++ programming. By the end of the
lab, students will gain practical experience in using variables, operators, and control structures to
implement simple arithmetic calculations.
Hardware/Software Tools:
Hardware: Desktop/Computer
Software Tool: MS Visual Studio 2013
Lab Description:
This lab focuses on implementing basic arithmetic operations in C++ programming. The students
will start by understanding the role of data types and variables to store numerical values and use
appropriate operators to perform basic arithmetic tasks. The lab will cover various arithmetic
operators such as addition (+), subtraction (-), multiplication (*), and division (/). Finally, the
students will use input/output functions to display the results clearly and in a user-friendly
format, reinforcing their skills in coding and debugging C++ programs.
Arithmetic Operators:
Arithmetic operations are performed using operators that allow you to manipulate numbers in
various ways. These operations include addition, subtraction, multiplication, and division. When
writing a program, you can use the arithmetic operators +, -, *, and / to carry out these
calculations. For example, the addition operator + adds two numbers together, the subtraction
operator - subtracts one number from another, the multiplication operator * multiplies two
numbers, and the division operator / divides one number by another.
Command Name Example Output
+ Addition 4+5 9
- Subtraction 8-5 3
* Multiplication 4*5 20
/ Division 19/3 6
% Remainder 19%3 5
1
, 1. Addition (+): The addition operator is used to add two values together. For example:
This example/code defines two integer variables, a and b, with values 5 and 3,
respectively. It then adds them together, stores the result in the variable result, and
displays the sum to the console.
2. Subtraction (-): The subtraction operator is used to subtract one value from another. For
example:
This code/example defines two integer variables, a and b, with values 5 and 3,
respectively. It then subtracts b from a, stores the result in the variable result, and
displays the difference to the console.
2