Array Basics in C++ : Find Sum

Video tutorial to show the basic use of arrays: Initialization, Declaration, Getting values from the users, finding sum of all the array elements etc.

Array is a collection of homogeneous data items.

Full Source Code

#include
#include

void main()
{
  //  int a[5] = { 1, 3, 2, 4, 5 }; declaration with initialization

  int a[5], sum = 0;
  clrscr();

  cout>a[i];

  cout

In this program we take input from the user and display the user entered numbers and find the sum of all the array elements and display it as well.

Elements are stored from the index number 0. i.e., if the array size is 5, the values will be stored in a[0], a[1], a[2], a[3], a[4];

Ex:
int a[5] = { 1, 3, 2, 4, 5 }; declaration with initialization
float a[5] = { 1.1, 2.0, 3.3, 1.3, 5.6 };

Video Tutorial: Array Basics in C++ : Find Sum



YouTube Link: https://www.youtube.com/watch?v=BfAa2koJv64 [Watch the Video In Full Screen.]



Output:
Enter 5 numbers
1
2
3
4
5
Input array is..
1
2
3
4
5
Sum of array elements: 15