Answer to Question #293664 in C for Piyu

Question #293664

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

1
Expert's answer
2022-02-03T15:28:29-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS