Advertisement
fouzimedfouni

MACRO Example

Jan 28th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.31 KB | None | 0 0
  1. #include <stdio.h>
  2. #define AND &&
  3. #define OR ||
  4. #define CHECK(A,B,C) if((A > B AND B > C) OR (B == 0 AND C < A )){printf(" A is greater than B, and B is greater than C");} else {printf(" your condition is not Achieved");}
  5. main()
  6. {
  7. int A,B,C;
  8.  
  9. printf(" A is : ") ;
  10. scanf("%d",&A);
  11.  
  12. printf(" B is : ") ;
  13. scanf("%d",&B);
  14.  
  15. printf(" C is : ") ;
  16. scanf("%d",&C);
  17.  
  18. CHECK(A,B,C);
  19.  
  20.  
  21.  
  22.     fflush(stdin);
  23.     getchar();
  24.    
  25. }
  26. // this is an example about "MACRO" in C language and MACRO is in the form of : #define MACRONAME VALUE
  27. //                                                                           or #define MACRONAME (parameter) ......like this example
  28. //                                                                            .........etc
  29. // and in this example we used it for 3 MACROS and they are : #define AND &&
  30. //                                                            #define OR ||
  31. //                                                            #define CHECK(A,B,C) if((A > B AND B > C) OR (B == 0 AND C < A )){printf(" A is greater than B, and B is greater than C");} else {printf(" your condition is not Achieved");}
  32. // and as you can see in the first example is : #define AND(MACRO) &&(value) and the second MACRO too
  33. // and we used it in the Third MACRO and it worked out so well for us :)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement