To compile-time initialization general form of mentalization flow then to compile-time also you can make that civilization the type identifier equal new type then square bracket they are not mentioned any number of elements in here but in this curly bracket we can give the value of the element okay then how many values you give here then this take that number of elements okay so value n like then we use here several elements in several elements and number value in time okay this is the way also you can decrease what’s the type identifier there’s a name of the array new type then square bracket okay they are not mentioned any number of them we can give the values then this is the first element this is the second element it’s like we can refer for the array when you are separated by the commas, okay all values are separate by the comma and what is the curly bracket value must be as in okay compatibility to the element type okay then check the type is the data type.
It might be this value also otherwise error of the implicit conversion from into double okay then you put them in here but for integer type the data sorry array type but you give the value is the double like there’s an income country declare and initialize the element in one steps, okay one step you can arrange length determined by the number of okay initialization value place inside the curly braces here is an example here is an in an array equal okay here four elements are there okay this is the one dimensional an array there’s a name of the array here and array new okay this is the way without this here char also because if you hear integer type but you are assigned the values in the yes okay new char without this one no you can ABC like then now is that this great is the ABC f, okay anyway you can declare the variable array type variable double depth new double this way okay in here if you want like button okay.
If you mentioned the two-element you must give the only two values in here is the third one is that depth equal double depth is the one dimensional the square bracket nothing is there inside the thing then it’s a one-dimensional array and if if you mention here if you give the number if we add one number here one more for this, okay the number of an index like you mentioned like that no lens we specify is not trickier but if you specify then you have to give for the number of elements that okay now is the array it is like certain here inch angle than this that I already mentioned is the very first element the 100th-second element is the 200 then this is the way we can a square bracket one is the second element is okay array type okay lens-specific the property of that class, okay that’s the length is the property of the array class and you can lose valid indexes so always length of the array minus one okay.
Then sometimes the array was outside the bound of the rays okay someday you can if the moon on negative okay there always the array index is the positive value start the zero to several elements minus one the maximum length plus element index is the number of element okay a total number of elements minus one or size of the array my response create and also okay I only explain but we’ll do the physical okay okay always this is the user system then we can import the whole class a system on window class forms okay name base then we are going to use the form in the system. The class is the name of the class object name this average if static one main method we are using the console application double average and then we are going to give for the 10 number of number 10 value for the score variable s area type in square brackets score equal new intent then after we say in the value i entered this line any value you can enter okay up to 10 values given here okay has given here 10 values.
I have given here this below here now I want to calculate the average then we want to add that all 10 values and divide by 10 times, okay then average this yes for me but here’s they are using the for loop okay we’re going to add that 10 numbers like first at the 10 number like okay add this number to certain number then after the second number the total is there then again the third number add that third number to that two numbers that like we only do that then we are using the for loop easy too okay calculate loop int i equals 0 that I list and score dot length okay score dot let me then I start the zero then up to nine you can continue then total equal total plus score i then first add the first number then second like then we can 10 time we can add the number then average equal total divided by score dot length total divided by square dot length then okay directly you can put the 10 but if the number of an element is changed again you had to give okay change here also.
But how many elements are there then okay divide by the total numbers then average we can find the first-order right line then we can get the output as average okay here is the register double okay again we wonder fine for that difference okay what is the difference with the array to that number how much light then that’s a record that’s a distance the distance equal press dot abs absolute average minus score okay but here some we are using the abs mean okay absolute value means to hold on positive value if you come for the results as a negative okay take that as a positive weight okay positive number okay the value is a positive not showing look at it, therefore, this is absolute, okay later you can study this side let’s not absolute abs that’s okay this is the method abs the method now you can use for the average also method square root their mathematical function is a vertical function that means that is the function absolute sign.
These are the under that mathematic meth classes under that subclass I say absolute method let’s clap okay this is the symbol example we do that in physically we start the lecture you can do it that is the array okay quickly we can do it any way you can study this material so already I gave all material to you okay but if you don’t know the number of elements you need to store then would ask you said to count the number of entries and use that the size when you allocate the array, okay oh otherwise you can give them more than that number okay because i we don’t know how we say I want to keep that to your attendant, okay but I don’t know sometimes if you allocate for only 20 okay names of that and then like but now we use how many participants is there okay 36 is there 30 right then I can’t keep it that you were, therefore, you can give for the number of allocated array okay you cannot get that it okay in an approach.
We are using the while loop that is the sentinel value after you can stop because sometimes you don’t know how many elements we are going to enter then sentinel values the extremely okay extreme or dummy value if you want to stop that, okay using the for each with array used to okay iterate through an array then we can use for there only this is the read-only access not right only read the element this is a general format is there for each type identifier and expression okay we don’t know if you use the foreign it okay it goes through the until end of the array but we don’t know how many arrays are there but we if you use them for which is the type but the type of the array this identifier in expression okay then you can see the statement okay identifies to iterate the variable the expression in the array is the array okay type should be might be there a type okay this is what is that right and now you can see here-string colors red green blue okay.
There are now any number of elements here but here we can see three elements are there okay and if you use the for each string in okay for each sorry string where VP in color this is the array in color then values that you can use for the console. When then we can get that output as a red-green-blue we can get that as a value as a color value we can use that is an is the array this is a string type because already there same like that is the value we’ve seen here we want to display this color array value then Val is that you can use but in here is the 4e that also you can use there’s a repetition I mentioned that if you use the phone for loop here we are using the for loop number of time we want to calculate the distance something okay already here we are using a score. Length in the for loop okay initial values after that maximum that how many times want to repeat this is the increment, okay, but in the four reaches, it is automatically taken the number of elements.
How many are is that if you like the like then that time going to repeat this the console on right line three times repeat this print the color this value color values then we use the four each okay this is the syntax is the type of the array and this is the well we are using that’s any element well in the column then that this value you can use here and in print for the three colors but other arrays elements are the other thing we can okay not in the here-string type if you use that indigenous type then you can use here well in that’s the number of the name of the array then you can get the output as that time that’s a for each this also repetition for loop while loop for each also you can there’s a repeated loop each loop equation.