Advertisement
fannyxmikasa

etonachent

Jun 3rd, 2021
1,002
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.39 KB | None | 0 0
  1. //ARITHMETIC/RELATIONAL/EQUALITY OPERATOR==========================================================
  2. #include <stdio.h>
  3.  
  4. void arithmetic(int x, int y)
  5. {
  6.     printf("Arithmetic Operators\n###################");
  7.    
  8.     printf("\n\nAddition (+)    = %d", x + y);
  9.     printf("\nSubtraction (-) = %d", x - y);
  10.     printf("\nMultiplication (*) = %d", x * y);
  11.     printf("\nDivision (//) = %d", x / y);
  12.     printf("\nModulus (%)   %d", x % y);
  13.    
  14. }
  15. void relational(int x, int y){
  16.     printf("\n\n###################\nRelational Operators");
  17.    
  18.     if (x > y){
  19.         printf("\n\n %d is greater than %d", x, y);
  20.     }
  21.     else if (x >= y){
  22.         printf("\n\n %d is greater than or equal to %d", x, y);
  23.     }
  24.     else if (x < y){
  25.         printf("\n\n %d is less than %d", x, y);
  26.     }
  27.     else if(x <= y)
  28.     {
  29.         printf("\n\n %d is less than or equal to %d", x, y);
  30.     }
  31. }
  32.  
  33. void equality(int x, int y){
  34.     printf("\n\n###################\nEquality Operators");
  35.    
  36.     if (x == y){
  37.         printf("\n\n %d is equal to %d", x, y);
  38.     }  
  39.     else {
  40.         printf("\n\n %d is not equal to %d", x, y);
  41.     }
  42. }
  43.  
  44. void unary(int x,int y){
  45.     printf("\n\n\n###################\nUnary Operators\n\n");
  46.    
  47.    
  48.     printf("Prefix  x = %d", ++x);
  49.     printf("\nPostfix   y = %d", y++);
  50.  
  51.     printf("\nY current value after postfix(y++) = %d", y);
  52.    
  53. }
  54. #include <stdio.h>
  55.  
  56. int main()
  57. {
  58.     int x = 3;
  59.     int y = 2;
  60.    
  61.     arithmetic(x, y);
  62.     relational(x, y);
  63.     equality(x, y);
  64.     unary(x, y);
  65.    
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement