arrays in c programming | declaration and initialization |

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi students let us continue with the topic arrays so I said arrays a group of related data items that share a common name Sonali now let us see what how we can declare arrays so the syntax for arrays is just you have to write the data type and the array name and the size of the array so this is a syntax of an atom let me take the examples for how to define declare an array let us take the float height 50 so what it means so here this is a float is a data type and height is an array name and the 50 is the size of the array so this declares this declares height height is the name of an array height to be an array containing 50 float elements so it contains that array height contains a 50 what type of elements those are the float elements flow datatype now second if you take int integer datatype here group I am taking the array name of size is 10 what this represents this declares group as an array so grouper as an array name which containing contain a maximum of 4/10 integer constants so it's having at an integer constants so this is about how to declare an array so suppose if you want to to represent to represent a set of fine embers if you want to represent a set of fine embers by an array it can be declared as it can be declared as how you can declare integer datatype is a arrayname with set of five elements so this is the Declaration of la so how can you represent it in the memory so this is a memory location so here this is a of zero we have to a is an array name it declaring the Phi elements so a of one we are giving the index names a of to a of three and last one is a of four so this array contains the four elements so sorry five elements so here the five storage locations each occupies two bytes wide occupied each two bytes each memory location occupies two bytes because we are using the data type int so the size of the index two bytes so it the computer reserves file storage locations so these are the five storage locations each having two bytes so if there are n elements in an array then subscription ranges from a fan elements in an array then the range is from 0 to n minus 1 so every time the it will starts from 0 and n with t minus 1 so here I had taken the fire elements so it starts from 0 and n with n minus 1 that is the fourth element for location so 0 to n minus 1 so this is how to declare an array now let us see how to initialize an array initialization o array so how you can initialize you just do the a lip just assign the elements to a but each data item so a of 0 is 10 a of 120 so let me write here you the neutral a of 120 a of 230 a of 340 and a of 450 so array into a of 5 elements this is the declaration now you have to initialize the values how you can initialize int a over array name a contains five data items of type integer and those values will be initialized with each data item is initialized with 10 20 30 40 50 so this is how in initialize an array can also be initialized at the time of declaration as here so at the time of declaration also you can directly initialize in the previous programs we are just initializing t is equal to 1 so here we are declaring the variable at the same time we are initializing the value to that variable so it is equal to 1 we are initializing the value to that variable so initialization and declaration can be done at the same time so in the same way here the array can be also initialized at the time of declaration so what here it represents so this is array so a of 0 a of 1 a of 2 a of 3 a of 4 so array of 5 elements so here we initialized a of 0 as 10 F 1 represents 20 a of 230 here for a of 340 a of 450 so this is how the values will be stored in the memory ok so this is about the initialization of Eric so we have seen the declaration and the initialization of L so in the next video I will explain about different types of arrays thank you
Info
Channel: Education 4u
Views: 60,833
Rating: 4.801156 out of 5
Keywords: arrays in c programming for beginners, arrays in c programming tutorial, arrays in c programming in english with examples, arrays in c language, declaring arrays, declaring array in c, how to declare array in c, how to use array in c programming, how to initialize an array in c, how to initialize an array in c programming
Id: i6m_NqnbN50
Channel Id: undefined
Length: 7min 18sec (438 seconds)
Published: Tue Feb 06 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.