-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoperators.dart
76 lines (55 loc) · 1.79 KB
/
operators.dart
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
void main() {
// declaring two numbers
int num1=10;
int num2=3;
// performing arithmetic calculation
int sum=num1+num2; // addition
int diff=num1-num2; // subtraction
int unaryMinus = -num1; // unary minus
int mul=num1*num2; // multiplication
double div=num1/num2; // division
int div2 =num1~/num2; // integer division
int mod=num1%num2; // show remainder
//Printing info
print("The addition is $sum.");
print("The subtraction is $diff.");
print("The unary minus is $unaryMinus.");
print("The multiplication is $mul.");
print("The division is $div.");
print("The integer division is $div2.");
print("The modulus is $mod.");
int userid = 123;
int userpin = 456;
// Printing Info
print((userid == 123) && (userpin== 456)); // print true
print((userid == 1213) && (userpin== 456)); // print false.
print((userid == 123) || (userpin== 456)); // print true.
print((userid == 1213) || (userpin== 456)); // print true
print((userid == 123) != (userpin== 456));//print false
int age = 10;
// print(value1 is String);
// print(age is !int);
//printing info
print(num1==num2);
print(num1<num2);
print(num1>num2);
print(num1<=num2);
print(num1>=num2);
// Increment and Decrement Operators
age+= 1; // Here age+=1 means age = age + 1.
print("After Addition Age is $age");
age-= 1; //Here age-=1 means age = age - 1.
print("After Subtraction Age is $age");
age*= 2; //Here age*=2 means age = age * 2.
print("After Multiplication Age is $age");
// age/= 2; //Here age/=2 means age = age / 2.
print("After Division Age is $age");
num2 = ++num1;
print("The value of num2 is $num2");
// reset value to 0
num1 = 0;
num2 = 0;
// post increment
num2 = num1++;
print("The value of num2 is $num2");
}