Question
8.12 LAB**: Program: Pointers In this programming assignment, you will write a C program that works with pointers and dynamically allocated arrays. You will ask
8.12 LAB**: Program: Pointers
In this programming assignment, you will write a C program that works with pointers and dynamically allocated arrays. You will ask the user for a size and then dynamically allocate the array of integers of that size, and use the pointer to the array for further calculations.
Write the main() that will do the following:
Take the size for the dynamically allocated array from the user.
Create myData as an integer pointer type variable. Dynamically allocate memory for an integer array using the input size.
Using the myData pointer and a loop, initialize the array member values to the index number that object exists in the array.
Loop through the filled array using the myData pointer and print out the array contents separated by space.
Also calculate the average of the array's data members and print it. The value should be shown with exactly 2 decimal places. The output must look exactly like this in terms of formatting. Below is an example for when the user enters 5.
Free the array when you are done.
0 1 2 3 4 average: 2.00
Save your main.c file and upload it below for grading.
In this programming assignment, you will write a C program that works with pointers and dynamically allocated arrays. You will ask the user for a size and then dynamically allocate the array of integers of that size, and use the pointer to the array for further calculations. - Write the main ( ) that will do the following: - Take the size for the dynamically allocated array from the user. - Create mydata as an integer pointer type variable. Dynamically allocate memory for an integer array using the input size. - Using the mydata pointer and a loop, initialize the array member values to the index number that object exists in the array. - Loop through the filled array using the myData pointer and print out the array contents separated by space. - Also calculate the average of the array's data members and print it. The value should be shown with exactly 2 decimal places. The output must look exactly like this in terms of formatting. Below is an example for when the user enters 5. - Free the array when you are done. 01234 average: 2.00 Save your main.c file and upload it below for grading
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