Question: Write in C language. Arrays may also be initialized. That is, instead of Junk, we can assign values to the elements at the time that

Write in C language.

Write in C language. Arrays may also be initialized. That is, instead

Arrays may also be initialized. That is, instead of Junk, we can assign values to the elements at the time that we declare the array. Here is the syntax for initializing an array. int my_array[]={100, 200, 300, 400}; Notice the size of the array is determined by the number of elements in the list on the right rather than by passing the size in the []. However, the array still doesn't know" its size, so you will need to store that information in a local variable. 1. Use the above code to initialize an array. 2. Write for loop in main() to print the values in the array to the screen. 100 200 300 400 3. Now move the for loop into its own function called printArray(). What argument(s) will printArray () need? What return type should it have? Hint: In C, when passing an array to a function, assume will also need to pass the size of the array. Again, do *not* use a global variable to contain the size of the array. We need to pass the size as an argument. Here is the basic syntax for a function prototype that takes an array parameter: double arrayFuntion (int a[], int size); 4. Test the function in main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!