Advertisement
horselurrver

Larger_of

Aug 2nd, 2016
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. void larger_of(double *x, double *y);
  3.  
  4. int main(void){
  5.     double a=123.0009;
  6.     double b=123.1239;
  7.     double *ptr1, *ptr2;
  8.     ptr1=&a;
  9.     ptr2=&b;
  10.     printf("Originally, a = %f and b = %f.\n", a ,b);
  11.    
  12.     larger_of(ptr1,ptr2);
  13.    
  14.     printf("Now, a = %f and b = %f.\n", a, b);
  15.    
  16. }
  17.  
  18. void larger_of(double *x, double *y){
  19.     if(x<y){
  20.         *y=*x;
  21.     } else{
  22.         *x=*y;
  23.     }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement