-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconditions.cpp
More file actions
61 lines (39 loc) · 1.05 KB
/
conditions.cpp
File metadata and controls
61 lines (39 loc) · 1.05 KB
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
#include<iostream>
using namespace std;
int main(){
int a = 10;
if(a=5){ // here the = operatore well true this condition and this statement well be run
cout<<"true";
}
else{
cout<<"false";
}
//--------------------------
cout<<endl;
int x = 0;
if(x==x++){ //the result of this code well be undefine conventionaly incrementing of x multiple time in single line can lead to undefine behaviour
cout<<"equal ";
}
else{
cout<<"not equal ";
}
cout<<endl;
//--------------------------
if(-1){
cout<<"non_true";
}
else{
cout<<"true";
}
//--------------------------
cout<<endl;
int c = 0;
if(c++ and --c){ // here the value of c first used then incfement and when c=0 then it gives faluse means one side is false other well not be excuted
cout<<"yes"; // the value of c increment to 1 and if conditon goes false and inside else value of c well printed
}
else{
cout<<"the vaue of c is "<<c;
}
//--------------------------
cout<<endl;
}