Write a c program to pass an entire array to a user defined function and multiply each element by 3 inside the function and print the elements of the array in main
#include <stdio.h>
void multiply_by_3(int* arr, int size)
{
for (int i = 0; i != size; ++i)
{
arr[i] *= 3;
}
}
int main()
{
int arr[10]{15, 18, 21, 24, 27, 30, 33, 36, 39, 42};
multiply_by_3(arr, 10);
for (int i = 0; i != 10; ++i)
{
printf("%d\t", arr[i]);
}
printf("\n");
return 0;
}
Comments
Leave a comment