Video Link: https://youtu.be/_57FcSBtJNU Tutorial Link: https://www.programiz.com/c-programming/c-operators
Addition +
Subtraction -
Multiplication *
Division /
Remainder %
Increment ++
Decrement --
#include <stdio.h>
int main() {
int x = 12;
int result = x + 8;
printf("%d", result);
return 0;
}
Another way:
#include <stdio.h>
int main() {
int x = 12;
printf("%d", x+8);
return 0;
}
Output
20
#include <stdio.h>
int main() {
double x = 12.57;
double result = x + 8.67;
printf("%.2lf", result);
return 0;
}
Output
21.24
#include <stdio.h>
int main() {
double x = 12.57;
int y = 8;
double result = x + y;
printf("%.2lf", result);
return 0;
}
Output
20.57
#include <stdio.h>
int main() {
int x = 12;
int result = x / 8;
printf("%d", result);
return 0;
}
Output
1
#include <stdio.h>
int main() {
double x = 12.00;
double result = x / 8.00;
printf("%.2lf", result);
return 0;
}
Output
1.50
#include <stdio.h>
int main() {
int x = 12;
int result = x % 8;
printf("%d", result);
return 0;
}
Output
4
#include <stdio.h>
int main() {
int x = 12;
printf("%d", ++x);
return 0;
}
Output
13
#include <stdio.h>
int main() {
int x = 12;
printf("%d ", --x);
return 0;
}
Output
11
#include <stdio.h>
int main() {
int x = (4 / 2) + (6 * 5) - 1;
printf(" %d", x);
return 0;
}
Output
31
Q. What is the value of x in the following code?
int x = 5 + 2 * 9 / 3 - 3;
Options
- 18
- 11
- 8
- Error
Answer: 3