Lab Objective: In this lab, students will create a C program that contains an array structure. They will
compile and debug their program using Visual Studio 2015.
Problem Statement
Write a program that takes n number of elements from user (where, n is specified by user), stores data in
an array and calculates the average of those numbers.
Use the below program template to answer each question. The program is created by answering all the
questions hence, do not skip any question.
Programming Shell Template
Instructions
1. Using the Xendesktop, open Visual Studio 2015. Create a new project and add a new .c file to the
project. Type the programming shell template as stated up above and continue with the following
steps below. Be sure to include comments throughout your program for readability purposes.
2. (Housekeeping): Declare the following variables in your program using appropriate data type.
When selecting a data type keep in mind the type of value you want to store, i.e., int, float,
character. Also, be sure to use conventional naming standards for all variable declarations.
n //variable used to store the number of values the user wishes to average
i //counter variable to loop through each array element
num[10] //array structure to hold 10 values
sum
average
(Hint): Since sum is going to be used for adding the value, it needs to be initialized to zero.
3. (Display Prompt): Write a printf() statement to ask user for the following message.
4. (Input): Add a scanf() statement to store user input for the number of values they wish to
process.
5. (Loop structure): Create a looping structure to catch any user input that may be out of the arrays
storage range. If the user types in a value less than 0 OR greater than 10 print out a message
telling the user that they entered an invalid number. Don’t forget to prompt the user to enter a
valid number and store that value just like you did not steps 1 and 2 above.
6. (Loop structure): Now, you will write a loop structure to store the user input of values to be
averaged into each element of the array.