C++ Arrays (With Examples)
C++ Arrays (With Examples)
C++ Arrays
In this tutorial, we will learn to work with arrays. We will
learn to declare, initialize, and access array elements in
C++ programming with the help of examples.
double grade[27];
Here,
Thank you for printing contentisatan
ourgrade array that can holdPlease
www.domain-name.com. a maximum of 27
check back soon for new contents.
elements of double type.
Search tutorials and examples
(/) the size and type of arrays cannot be changed
In C++,
www.domain-name.com
after its declaration.
dataType arrayName[arraySize];
For example,
int x[6];
Here,
array[index];
Thank you for printing our content at www.domain-name.com. Please check back soon for new contents.
Here, the size of each element is increased by 4. This is
becauseSearch tutorials
the size of int andisexamples
4 bytes.
(/)
www.domain-name.com
For example,
mark[3] = 9;
int main() {
return 0;
Output
Thank you for printing our content at www.domain-name.com. Please check back soon for new contents.
The numbers are: 7 5 6 12 35
A DV E RT I S E M E N T S
www.domain-name.com
int numbers[5];
return 0;
Output
Enter 5 numbers:
11
12
13
14
15
elements.
www.domain-name.com
double sum = 0;
double count = 0;
double average;
sum += n;
++count;
Output
Their Sum = 92
Next Tutorial:
(/cpp-
Multidimensional programming/multidimensional-
Arrays arrays)
Previous Tutorial:
C++ Return (/cpp-programming/return-
reference)
Reference
Share on:
(https://www.facebook.com/sharer/sharer.php? (https://twitter.com/intent/tweet?
u=https://www.programiz.com/cpp- text=Check%20this%20amazing%20art
Thank you for printing programming/arrays)
our content at www.domain-name.com. Please check back programming/arrays)
soon for new contents.
A DV E RT I S E M E N T S
Related Tutorials
C++ Tutorial
(/cpp-programming/ranged-for-loop)
C++ Tutorial
(/cpp-programming/pointers-arrays)
C++ Tutorial
(/cpp-programming/passing-arrays-function)