Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

Students also viewed these Databases questions

Question

How do members envision the ideal team?

Answered: 1 week ago