Solution Review: Multiply Array Elements by 3
Follow the step-by-step instructions to multiply array elements by 3.
We'll cover the following...
Solution
Press the RUN button and see the output!
Press + to interact
# include <stdio.h>void modifyArray ( int *arr, int n ) ;int main( ){int i ;static int array[ ] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } ;printf ( "\nOriginal Array is:\n" ) ;for ( i = 0 ; i < 10 ; i++ )printf ( "%d ", array[ i ] ) ;modifyArray ( array, 10 ) ;printf ( "\n\nModified Array is: \n" ) ;for ( i = 0 ; i < 10 ; i++ )printf ( "%d ", array[ i ] ) ;return 0 ;}void modifyArray ( int *arr, int n ){// Declares a variable iint i ;// for loop to traverse the arrayfor ( i = 0 ; i < n ; i++ ){// Multiply current element by 3*arr = *arr * 3 ;// Move to the next elementarr++ ;}}
Explanation
We ...
Access this course and 1400+ top-rated courses and projects.