Experiment_3
To use operators to add two numbers.
VS Code
Airthmetic operators are symbols used in programming to perform operations on variables and values. They are important to writing expressions and making decisions in code.
Addition (+): Adds two operands. Example: a + b Subtraction (-): Subtracts the second operand from the first. Example: a - b Multiplication (*): Multiplies two operands. Example: a * b Division (/): Divides the numerator by the denominator. Example: a / b Modulus (%): Returns the remainder of a division operation. Example: a % b
-
Start
-
Declare three integer variables: a, b, and c.
-
Prompt and Read First Number
-
Output: "Enter num 1: ". Read the input value and store it in variable a. Prompt and Read Second Number
-
Output: "Enter num 2: ". Read the input value and store it in variable b. Calculate the Sum
-
Compute the sum of a and b and store the result in variable c. Output the Result
-
Output the result: "The No. is: " followed by the value of c.
-
End
We learnt to use the basic arithmetic operators in C++.