fork download
  1. // Online C compiler to run C program online
  2. #include <stdio.h>
  3.  
  4. void testFunction(int arr[], int n) /// call by reference
  5. {
  6. for(int i=0; i<n; i++)
  7. {
  8. arr[i] *= 100;
  9. }
  10. }
  11.  
  12. void printArray(int arr[], int n)
  13. {
  14. printf("The elements of the array: ");
  15. for(int i=0; i<n; i++)
  16. {
  17. printf("%d ", arr[i]);
  18. }
  19. printf("\n");
  20. }
  21.  
  22. int main() {
  23. int n;
  24. scanf("%d", &n);
  25. int arr[n];
  26. for(int i=0; i<n; i++)
  27. {
  28. scanf("%d", &arr[i]);
  29. }
  30.  
  31. printArray(arr, n);
  32. testFunction(arr, n); /// call by reference
  33. printArray(arr, n);
  34.  
  35. int m;
  36. scanf("%d", &m);
  37. int arrB[m];
  38. for(int i=0; i<m; i++)
  39. {
  40. scanf("%d", &arrB[i]);
  41. }
  42. printArray(arrB, m);
  43.  
  44.  
  45. return 0;
  46. }
  47.  
Success #stdin #stdout 0.01s 5304KB
stdin
5
1 2 3 4 5
10
5 6 9 8 7 4 1 0 2 3
stdout
The elements of the array: 1 2 3 4 5 
The elements of the array: 100 200 300 400 500 
The elements of the array: 5 6 9 8 7 4 1 0 2 3