0
Any body can me help koi btayega ki array kya hota h matlb ki array ka kya use h iska kya matlb hota j java nd c++ me
java
4 odpowiedzi
+ 11
int some_array[5] = {1, 2, 4, 6, 7};
cout << some_array[0];
// outputs 1
cout << some_array[4];
// outputs 7
+ 11
To store large number of values. e.g.
int array[100];
instead of declaring 100 variables.
0
what's use of array. plz defined
0
whenever we use int for declaring interger type variables the storage for storing varible get created randomly anywhere in the ram. The value of variable get stored in ram because it is Random Access Memory, this means we can access the value of our variable many times in a program or modify it. Now in array , lets say 'int my_array[10]'
in this a space in ram is booked for 10 integer type variable or may be constant, but the space is not formed randomly anywhere instead it is continuous so that the 10 variable can be stored in one place for modifying or accessing the variable easily in future.
ADVANTAGE OF ARRAY
1.array is used for creating large no. of variables for example = int array_name[1000]
in this a space for 1000 integer type variable is created in an instant. imagine how would you create this with int !
2. as the space for creating n integer is continuous in ram , so it is easy for compiler to access the variables.
DECLARING ARRAY
array can be many type int , float,double, string etc.
for eg. float array and[3636]
GETTING VALUES OF VARIABLE IN A ARRAY
int array[6]
for( int i =0; i<6;i++)
cin>>array[i];
// loop for getting 6 values from user.
USES- I can remember one use that is printing Fibonacci series . if you want to know how to do this you can comment.
thats all. I hope you understand