-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1.4Operators.cpp
45 lines (36 loc) · 1.25 KB
/
1.4Operators.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include<conio.h>
using namespace std;
//Operators are used to perform operations on variables and values.
/************
+ Addition Adds together two values x + y
- Subtraction Subtracts one value from another x - y
* Multiplication Multiplies two values x * y
/ Division Divides one value from another x / y
% Modulus Returns the division remainder x % y
++ Increment Increases the value of a variable by 1 ++x Pre increment/Post Increment
-- Decrement Decreases the value of a variable by 1 --x
**************/
int main() {
int sum1 = 100 + 50; // 150 (100 + 50)
int sum2 = sum1 + 250; // 400 (150 + 250)
int sum3 = sum2 + sum2; // 800 (400 + 400)
//The addition assignment operator (+=) adds a value to a variable:
int x = 10;
x += 5; //x=x + 3
/***Comparison Operator
== Equal to x == y
!= Not equal x != y
> Greater than x > y
< Less than x < y
>= Greater than or equal to x >= y
<= Less than or equal to x <= y
*******/
/*********
&& Logical and Returns true if both statements are true x < 5 && x < 10
|| Logical or Returns true if one of the statements is true x < 5 || x < 4
! Logical not Reverse the result, returns false if the result is true !(x < 5 && x < 10)
*************/
return 0;
}
//Navjot Singh Prince