-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathnewe.cpp
57 lines (49 loc) · 1.73 KB
/
newe.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
46
47
48
49
50
51
52
53
54
55
56
57
// C Program to Demonstrate the working concept of
// Operators
#include <stdio.h>
int main()
{
int a = 10, b = 5;
// Arithmetic operators
printf("Following are the Arithmetic operators in C\n");
printf("The value of a + b is %d\n", a + b);
printf("The value of a - b is %d\n", a - b);
printf("The value of a * b is %d\n", a * b);
printf("The value of a / b is %d\n", a / b);
printf("The value of a % b is %d\n", a % b);
printf("The value of a++ is %d\n",
a++); // First print (a) and then increment it
// by 1
printf("The value of a-- is %d\n",
a--); // First print (a+1) and then decrease it
// by 1
printf("The value of ++a is %d\n",
++a); // Increment (a) by (a+1) and then print
printf("The value of --a is %d\n",
--a); // Decrement (a+1) by (a) and then print
// Assignment Operators --> used to assign values to
// variables int a =3, b=9; char d='d';
// Comparison operators
// Output of all these comparison operators will be (1)
// if it is true and (0) if it is false
printf(
"\nFollowing are the comparison operators in C\n");
printf("The value of a == b is %d\n", (a == b));
printf("The value of a != b is %d\n", (a != b));
printf("The value of a >= b is %d\n", (a >= b));
printf("The value of a <= b is %d\n", (a <= b));
printf("The value of a > b is %d\n", (a > b));
printf("The value of a < b is %d\n", (a < b));
// Logical operators
printf("\nFollowing are the logical operators in C\n");
printf("The value of this logical and operator ((a==b) "
"&& (a<b)) is:%d\n",
((a == b) && (a < b)));
printf("The value of this logical or operator ((a==b) "
"|| (a<b)) is:%d\n",
((a == b) || (a < b)));
printf("The value of this logical not operator "
"(!(a==b)) is:%d\n",
(!(a == b)));
return 0;
}