0

I dont understand Whats is array pls help me

28th Dec 2016, 1:20 PM
alinasfi
5 Respuestas
+ 1
consider you want to represent colors with a set of red green and blue percentage. you could use an array to strore the quantity of red, the quantity of green and the quantity of blue that are necessary to obtain the desired color. for example the desired color will be an array of integers values int desiredColor[]={red%, green%, blue%}; int red[ ]={100, 0, 0};//where 100 is the percentage of red and 0 is the percentage of green and blue int green[ ]={0, 100, 0}; int purple[ ]={100, 0, 100} // mixing blue and red you get purple int white[ ]={100, 100, 100}; int grey [ ]={50, 50, 50}; int black [ ]={0, 0, 0}; if you have access to an arduino or the Processing IDE and an Rgb led you will practically use the array to change the light color of the led.
28th Dec 2016, 1:51 PM
seamiki
seamiki - avatar
+ 1
when you want to store more than one value instead of defining each and every value with variable you can simply declare an array to reduce your work.
29th Dec 2016, 8:08 AM
Rajveer
0
Imagine like you have to take 100 variables then instead of writing thos 100 variables you simply use arrays that's at very basic level and there are also many other benefits of it
28th Dec 2016, 4:02 PM
Amol Jandial
Amol Jandial - avatar
0
hi please y can help me to understand the algorithme I have a exam and I d'ont know anything please help me please
29th Dec 2016, 8:14 AM
alinasfi
0
Simply array is a sequence of values where each value is given its index. Array can defined in any datatype such as double, int, String & other data types. Each value in an array is given index position and remember array always starts from index position "0". Simple syntax to define array: datatype[ ] arrayname = new datatype[n]; Where n is the maximum length of an array. Lets give an example: //initializing string array String[ ] motorsArray = new String [10]; motorsArray = {"honda", "mercedes","bmw", "hyundai","ferrari"}; /* String "honda" holds position = 0 String "mercedes" holds position = 1 & so on others */ Note: you can directly assign values to an array without defining its maximum length. String[ ] exampleArray = { "test1", "test2", "test3"}
6th Jan 2017, 2:44 AM
Rishav Chudal
Rishav Chudal - avatar