Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started