arrays in c programming | one dimensional |

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi students let us continue with the topic arrays in computer programming so in the previous video I explained about how to declare an array and how to initialize an any now let us see different types of arrays actually the race or broadly classified into three types arrays are classified into three types so one is you can one dimensional array one dimensional arrays two dimensional arrays and multi-dimensional arrays so these are the three different types of arrays multi-dimensional arrays so let us discuss one by one so first I will explain about what is the one dimensional array so with the example let us take the first one one dimensional array so this one dimensional array can be initialized means any of the other dimension is the two our dimensional for multi dimensional any Erik can be initialized in two ways it can be initialized in initialize in two ways so what are that you can initialize at compile time compile time initialization or you can call it as a run time initialization run time initialization so either one dimensional two dimensional multi dimensional you can initialize the array at compile time or at runtime so let us see what does this a compile time and what is at run time initialization by using the one dimensional array so here I am writing the program so fresh people so here I'm writing the program for one dimensional array now I'm explain the concept of one dimensional array so in this one dimensional array can be initialized it compile-time and at runtime now let us write the program for compile time initialization so at the compile time I am initializing the variables so compile time initialization means you have to initialize the elements or the values in the program itself while writing the program only so compile time initialization and sequential access sequential axis using for loop so using for loop how to access the array that is a one dimensional array in compile time initialization now writing the main program hash include STD I would not hit okay now writing the main program may now declaring the initializing the values the declaration and initialization is running at the same time so integer is a data type of array name a with the five elements so those five elements are initializing 10 20 30 40 50 so this you call it as a compile time initialization means you are writing the program the entering the values in the program itself okay so you can't change the values after trunkman okay after compiling the program so these values you call it as a compile time initialization this type of initialization you call it as compile time initialization now I'm taking the variable int I because I have to access the for loop so for that I am taking the variable I CLR is here to clear the previous screen now I am writing the printf so printf mensa off array or so the elements of array or that has to print on the screen now I am right entering the far loop for I is equal to zero I less than 5 I plus plus because less than five means be 0 1 2 3 4 up to 4 it can access means 0 to 4 means total 5 elements will get so it has to store those values and print on this screen so that's why printf % LD that value has to be printed first a of 0 so a of 0 will value 10 will be printed okay let's see hitch so this you call it as a 1-dimensional so let me explain this so this is a 1 dimensional array and this if you declare that in the program you call it as a compile time compile time initialization so this you call it as a compile time initialization because you are initializing the values in the program itself means you are not entering from the keyboard means at the runtime you are not entering the values so at the starting of the program also your your enter the values so that you call it as a compile time initialization so when what is this so whenever these values will be whenever you declare and initialize the values these values will store in the memory so this you call it as a storing how it stores so in the array a of 5 means first it takes a of 0 a of 1 a of 2 a of 3 a of 4 ok so after that elements of array or that has to be entered and save it on the memory it has to print on the screen as well as it has to store it in the memory so for that we will use the printf so first in the far loop i of 0 a of 0 means it enters 10 next again loop rotator a of 120 a of 230 a of 440 a sorry of 340 or 450 so after that it exits of our loop and a exists the main block so this is the compile time initialization then what will be the output for this program so the output for this program is elements of array or just when 20 30 40 50 so this is the output this program you call it as a 1-dimensional compile time initialization and sequential access using for loop now let us see program fire at runtime so to know the difference between this two I am writing two programs for this one dimensional array so now I am writing the program for one dimensional but for run program for runtime initialization so what it means runtime initialization and sequential access using for loop so let us see the one dimensional array initializing the values at runtime hash include stdio.h now writing the main program so here I am declaring the array I am Here I am NOT initializing only I am declaring the array of the same example I am taking so that you will you won't be confused you will sure you will know the difference between what is at runtime initialization and the compile time initialization so the difference here is in the previous program I declared the values along with initialization so here I am just declaring the array I am NOT entering the values because I trunk time I will enter the values so into a of I and in Tai variable I declare now I am writing the printf enter 5 elements sorry enter 5 elements so 5 elements have to be entered so from so that 5 elements has to be entered from keyboard so if you want to enter the values from keyboard Atlanta you have to write the scanner so I have to enter 5 elements so you just use the for loop for I is equal to 0 I less than Phi I plus plus now write the scanner to read the values from keyboard % LD am present here Phi it means first a of 0 it enter values at runtime and it takes the next a of 1 a of I so in the characters location second value will be entered and second a of 2 means I is equal to 2 a of 3 a of 4 so up to 0 to 4 the values will be read from the keyboard and saved it on the memory location so this is the for loop here what it's saying this polyp is used for storing or assigning values of element of an array so it's storing the values of element of n every now I am writing the printer again printer so what I have to write I have 2 elements so it have elements of array or so already I enter the elements enter 5 elements means it enters or elements now elements of array or fire I is equal to 0 I less than 5 I plus plus so what is the use of this for so here it accessing accessing the elements of array so here storing their values of elements of array and this for loop is for accessing the elements of L so here what I had to write I have to print the value printf % LD a off I value has to be printed already I enter the value so that value has to print on the screen so that is the 10 20 30 40 50 so those values I entered at the runtime close the main problem then what will be the output here so first it appears sorry output so what will be the output first it's saying enter 5 elements so whenever it sees this message those values are have to enter at the runtime so here I enter 10 20 30 40 50 so after that whenever press enter it a message will be a pair elements elements of array or so those values will be stored in the memory location and also print on the screen 10 20 30 40 50 so this is about the one dimensional array for compiling time initialization and at runtime initialization thank you
Info
Channel: Education 4u
Views: 95,120
Rating: 4.81949 out of 5
Keywords: arrays in c, arrays in c programming for beginners, arrays in c programming lectures, arrays in c programming examples, one dimensional array in c tutorial, one dimensional array in c programming, one dimensional array in c programming examples, one dimensional array in c language, types of arrays in c, arrays tutorial for beginners, c language arrays tutorial, c language arrays programs
Id: 7CPgjj3mKU4
Channel Id: undefined
Length: 12min 35sec (755 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.