C 12
Function_max Guest on 5th April 2021 12:52:13 AM
  1. #include <stdio.h>
  2. #define min(a,b) (a<b)?a:b
  3.  
  4. int max(int, int);  // function prototype declaration, not necessary for ANSI C
  5.  
  6. int main(){
  7.  
  8.   int a,b,c;
  9.   printf("Input two integers separated by comma, e.g. 2,3\n");
  10.   scanf("%d,%d",&a,&b);
  11.   c = max(a,b);
  12.   printf("Max is %d\n", c);
  13.  
  14.   c = min(a,b);   /* string "min(a,b)" will be subtituted by string "(a<b)?a:b" in preprocessing*/
  15.   printf("Min is %d\n", c);
  16.  
  17. }
  18.  
  19. int max(int x, int y){
  20.   int z;
  21.   z = x > y? x:y;
  22.   return(z);
  23. }

Paste-bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.