0
What's a pointer and an array?
I'm a little confused about this please help Also I don't understand the multi-dimensional arrays
2 Answers
+ 1
Pointers are the variables that hold address. Not only can pointers store address of a single variable, it can also store address of cells of an array.
+ 1
An array is a collection of things of the same type for example:
imagine you want to have 50 students grades, using built in variables you have to create 50 variables like the next example:
int firstGrade = #; // this # means x random number
int secondGrade = #
...and so on
Using the arrays you can store any numbers off values using position starting from 0. what do i mean? this:
first: to declare an array this is the concept: type of variable- name of array-[cuantity]. in c++ will be like this: int studentList[50]. this 50 means how many elements will have my array. i ve put 50 because imagine that i have 50 students.
how can u asign a value in c++?
using the array position for example:
int a[50] // this is declaring an array, and how many elements will have;
a[0] = 75;
a[1] = 73;
in this example im saying that the first position in the array will have the first student grade = 75.. and so on.
in c++ if you want to show the first value of the array will be like this
cout<<a[0]<<endl;
or if you want to capture the first value from a keyboard will be like this:
cin>>a[0];