Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.89 KB | None | 0 0
  1. /*********************************
  2. * Class: MAGSHIMIM C2            *
  3. * Week:                          *
  4. * Name:                          *
  5. * Credits:                       *
  6. **********************************/
  7.  
  8. #include <stdio.h>
  9.  
  10. #define SIZE 11
  11.  
  12. void printAfterX(int* arr, int n, int* x);
  13.  
  14. int main(void)
  15. {
  16.     int arr[] = { 4 ,8 ,6 ,2 ,1 ,3 ,5 ,7 ,8 ,9 ,5 };
  17.     int offset = 0;
  18.     printf("Please enter an offset to search in the array's address domain: ");
  19.     scanf("%d", &offset);
  20.     printAfterX(arr, SIZE, arr + offset);
  21.     getchar(); //Cleaning the buffer
  22.  
  23.     getchar();
  24.     return 0;
  25. }
  26.  
  27. /*
  28. Function that print from the array after x
  29. input: the arr the size of the arr and the x
  30. output:none
  31. */
  32. void printAfterX(int* arr, int n, int* x)
  33. {
  34.     if (x < arr || x > n + arr)
  35.     {
  36.         printf("Not in the array.\n");
  37.     }
  38.     else
  39.     {
  40.         for (x = x + 1; x < n + arr; x += 1)
  41.         {
  42.             printf("%d ", *x);
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement