Sumana_19

csed6h1

Apr 17th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include <stdio.h>
  2. #define f1(a,b,c) for(a=b;a<=c;a++)
  3. #define f(a,b,c) for(a=b;a<c;a++)
  4. void findDifference(int ar[],int n);
  5.  
  6. int main(void) {
  7.      
  8.      int n,i;
  9.      scanf("%d",&n);
  10.      int ar[n];
  11.      f(i,0,n)
  12.      scanf("%d",&ar[i]);
  13.      printf("First Difference:");
  14.      findDifference(ar,n);
  15.      printf("Second Difference:");
  16.      findDifference(ar,n-1);
  17.      printf("Third Difference:");
  18.      findDifference(ar,n-2);
  19.      
  20.      
  21.      return 0;
  22. }
  23.  
  24. void findDifference(int ar[],int n)
  25. {
  26.     int i;
  27.    
  28.     f(i,0,n-1)
  29.    {   ar[i]= ar[i+1]-ar[i];
  30.        printf("%d ",ar[i]);
  31.    }
  32.    printf("\n");
  33.    
  34. }
Add Comment
Please, Sign In to add comment