answersLogoWhite

0


Best Answer

#include

using std::cin;
using std::cout;
using std::endl;

int main()
{
const int numOfElements = 5;//defines how many elements are in your array
double arr[numOfElements] = {0.0};
cout << endl << "Enter " << numOfElements << " for your array";
for (int i = 0; i < numOfElements; i++)
{
cout << endl << (i + 1) << " element: ";
cin >> arr[i];
}

double sum = 0.0;
for (int i = 0; i < numOfElements; i++)
{
sum += arr[i];

}

cout << endl << "Average is: " << (sum/numOfElements) << endl;

system("PAUSE");
return 0;

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you create a program to store number in array and to find the avg of the number using c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Make a C programming that displays the first four perfect numbers?

create a program that iterates until it finds a perfect number, then store that perfect number into an array. Continue iterating until you find three more. Then, you have an array of four perfect numbers.


How do you initialize an array variable in java program?

An array in java is a collection of items stored into a single unit. The array has some number of slots (elements), each slot in the array can hold an object or a primitive value. Arrays in java are objects that can be treated just like other objects in the languageArrays can contain any type of element value , but we can't store different types in a single array. We can have an array of integers or an array of strings or an array of arrays.To create an array in java ,use three steps1. Declare a variable to hold the array2. Create a new array object and assign it to the array variable3. Store things in that array


Could array may have elements that are numbers and strings?

In Java:Not as primitives; but I believe you could create an array of Objects, and then initialize the elemnets as subtypes of the Object class, i.e., any class. I don't think this would be very practical (in Java); if (for example) you need to store information about people's names with their ages, create a class called "Person" that has those two attributes, then create an array of Persons.In Java:Not as primitives; but I believe you could create an array of Objects, and then initialize the elemnets as subtypes of the Object class, i.e., any class. I don't think this would be very practical (in Java); if (for example) you need to store information about people's names with their ages, create a class called "Person" that has those two attributes, then create an array of Persons.In Java:Not as primitives; but I believe you could create an array of Objects, and then initialize the elemnets as subtypes of the Object class, i.e., any class. I don't think this would be very practical (in Java); if (for example) you need to store information about people's names with their ages, create a class called "Person" that has those two attributes, then create an array of Persons.In Java:Not as primitives; but I believe you could create an array of Objects, and then initialize the elemnets as subtypes of the Object class, i.e., any class. I don't think this would be very practical (in Java); if (for example) you need to store information about people's names with their ages, create a class called "Person" that has those two attributes, then create an array of Persons.


What is string array?

A string array is an array whose contents are strings.An array is when you use a single variable names to store different data items. The data items are distinguished by a number (sometimes by more than one).A string is a data type used to store texts. It may contain letters, digits, or other symbols.A string array is an array whose contents are strings.An array is when you use a single variable names to store different data items. The data items are distinguished by a number (sometimes by more than one).A string is a data type used to store texts. It may contain letters, digits, or other symbols.A string array is an array whose contents are strings.An array is when you use a single variable names to store different data items. The data items are distinguished by a number (sometimes by more than one).A string is a data type used to store texts. It may contain letters, digits, or other symbols.A string array is an array whose contents are strings.An array is when you use a single variable names to store different data items. The data items are distinguished by a number (sometimes by more than one).A string is a data type used to store texts. It may contain letters, digits, or other symbols.


How can you dicribe array?

An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.

Related questions

Make a C programming that displays the first four perfect numbers?

create a program that iterates until it finds a perfect number, then store that perfect number into an array. Continue iterating until you find three more. Then, you have an array of four perfect numbers.


How can you store Class properties in Array in c?

Yes, you can create array that will store class properties. But all of them have to be of the same type.


How do you initialize an array variable in java program?

An array in java is a collection of items stored into a single unit. The array has some number of slots (elements), each slot in the array can hold an object or a primitive value. Arrays in java are objects that can be treated just like other objects in the languageArrays can contain any type of element value , but we can't store different types in a single array. We can have an array of integers or an array of strings or an array of arrays.To create an array in java ,use three steps1. Declare a variable to hold the array2. Create a new array object and assign it to the array variable3. Store things in that array


A travel agent wants a program to store an alphabetical list of winter holiday destinations State the most efficient way to store lists using a programming language?

The most efficient way to store a list is with an array.


Could array may have elements that are numbers and strings?

In Java:Not as primitives; but I believe you could create an array of Objects, and then initialize the elemnets as subtypes of the Object class, i.e., any class. I don't think this would be very practical (in Java); if (for example) you need to store information about people's names with their ages, create a class called "Person" that has those two attributes, then create an array of Persons.In Java:Not as primitives; but I believe you could create an array of Objects, and then initialize the elemnets as subtypes of the Object class, i.e., any class. I don't think this would be very practical (in Java); if (for example) you need to store information about people's names with their ages, create a class called "Person" that has those two attributes, then create an array of Persons.In Java:Not as primitives; but I believe you could create an array of Objects, and then initialize the elemnets as subtypes of the Object class, i.e., any class. I don't think this would be very practical (in Java); if (for example) you need to store information about people's names with their ages, create a class called "Person" that has those two attributes, then create an array of Persons.In Java:Not as primitives; but I believe you could create an array of Objects, and then initialize the elemnets as subtypes of the Object class, i.e., any class. I don't think this would be very practical (in Java); if (for example) you need to store information about people's names with their ages, create a class called "Person" that has those two attributes, then create an array of Persons.


What is string array?

A string array is an array whose contents are strings.An array is when you use a single variable names to store different data items. The data items are distinguished by a number (sometimes by more than one).A string is a data type used to store texts. It may contain letters, digits, or other symbols.A string array is an array whose contents are strings.An array is when you use a single variable names to store different data items. The data items are distinguished by a number (sometimes by more than one).A string is a data type used to store texts. It may contain letters, digits, or other symbols.A string array is an array whose contents are strings.An array is when you use a single variable names to store different data items. The data items are distinguished by a number (sometimes by more than one).A string is a data type used to store texts. It may contain letters, digits, or other symbols.A string array is an array whose contents are strings.An array is when you use a single variable names to store different data items. The data items are distinguished by a number (sometimes by more than one).A string is a data type used to store texts. It may contain letters, digits, or other symbols.


How can you dicribe array?

An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.


How can two single dimensional array values be stored in a third single dimensional array?

You need to create a new array with enough elements to cater for both arrays. Thus if the first array has 10 elements and the second has 5, you must create a 15 element array to store both. You then copy elements from the first array into the third and immediately follow with the elements from the second. Note that the first two arrays must be of the same type. You cannot combine an array of numeric values with an array of strings, for instance.


How do arrays differ from single memory position variables?

A single memory position variable can store only one value of its type. An array can store n number of values, where n is the size of the array.


How create swap program in c?

The best way to explain how to make a swap function in C is through an example: int x = 1; int y = 2; int tmp = x; New variable (temporary) is used to store the old x value. x = y; So now both x and y are equal to 2. y = tmp; y is now equal to 1. So after this function x is equal to 2 and y is equal to 1. To create a swap program you must apply this function in some way. One example being the bubble sort. for (j = 0; j &lt; n; j++) { for (i = 0; i &lt; n; i++) { if (array[i-1] &gt; array[i]) { int tmp = array[i-1]; array[i-1] = array[i]; array[i] = tmp;


Is there a way to create variables as needed in C based on user input?

Yes. You can store any number of values input at runtime using a variable-length array or any other sequence container such as a list.


Write a java program to print the result in the series?

If you have the series stored in an array, you loop through the array and print each array element in turn. Another possibility is to print out the numbers in the series as you generate them. In that case, you may not need to store anything (depending on the series, of course).