C++ Programming Tutorial 14: Compound Data Types - Arrays :: Videos



Description:


In this video we are talking about:

  • What is an Array?
  • Initializing an Array.
  • Accessing the value of an Array.
  • Character Sequence or Character Array.

What is an Array?

  • A Way of storing multiple values in only one identifier.
  • If you have three different int values stored in an int array, then it can be represented as:
  • Index: 0 1 2
    Values: Value1 Value2 Value3

Declaring an array.

  • An array of integer named MyArray to store 3 values can be declared as:
    • int MyArray[3]
  • Basic syntax would be: 
    • type Identifier[Number of Elements]

Initializing an array

  • When declaring an array in local scope, like in a function, without specifying a value, each element in the array will have an undetermined value, where as global and static array of fundamental data types will be initialized to 0.
  • To assign a value while declaring, you have enclose the values in { } and separate by a comma. 
  • For Example:
    • int MyArray[3] = {7, 256, 1024}

Accessing the value:

  • Each value in the array can be accessed to read and write by calling the array variable in following format:
    • ArrayName[Index]
  • Example:
    • int MyArray[7] = {7, 256, 1024, 77, 88, 12};
      MyArray[6] = 100;
      int X = MyArray[5];

Character Sequence:

  • Strings data types are just a sequence of characters, so char array and strings are interchangeable.
  • Char sequence should end with null character '\\0'

Have a look at the sample program Array.cc which can be downloaded from below:

Resource files:

Thank you for watching. Please comment and subscribe.


Comments:

Please login to post your thoughts!
 



amar2515

i want to no hw to write 2 dimenssional array .and swapping of 2 array .how to use pointer in calling a function.

an after seeing your video of function 2....i tried to solve problem it worked excellent...please give trick to solve this

           *

          ** 

         ***

        ****

onconsole screen..

 



Login

Username:
Password:
Don't have an account?
Register here
Register

Subscribe Youtube



Network DigitalStage.org


Some interesting stuffs