Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ARITHMETIC/RELATIONAL/EQUALITY OPERATOR==========================================================
- #include <stdio.h>
- void arithmetic(int x, int y)
- {
- printf("Arithmetic Operators\n###################");
- printf("\n\nAddition (+) = %d", x + y);
- printf("\nSubtraction (-) = %d", x - y);
- printf("\nMultiplication (*) = %d", x * y);
- printf("\nDivision (//) = %d", x / y);
- printf("\nModulus (%) %d", x % y);
- }
- void relational(int x, int y){
- printf("\n\n###################\nRelational Operators");
- if (x > y){
- printf("\n\n %d is greater than %d", x, y);
- }
- else if (x >= y){
- printf("\n\n %d is greater than or equal to %d", x, y);
- }
- else if (x < y){
- printf("\n\n %d is less than %d", x, y);
- }
- else if(x <= y)
- {
- printf("\n\n %d is less than or equal to %d", x, y);
- }
- }
- void equality(int x, int y){
- printf("\n\n###################\nEquality Operators");
- if (x == y){
- printf("\n\n %d is equal to %d", x, y);
- }
- else {
- printf("\n\n %d is not equal to %d", x, y);
- }
- }
- void unary(int x,int y){
- printf("\n\n\n###################\nUnary Operators\n\n");
- printf("Prefix x = %d", ++x);
- printf("\nPostfix y = %d", y++);
- printf("\nY current value after postfix(y++) = %d", y);
- }
- #include <stdio.h>
- int main()
- {
- int x = 3;
- int y = 2;
- arithmetic(x, y);
- relational(x, y);
- equality(x, y);
- unary(x, y);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement