Answer to Question #3189 in C++ for Babi

Question #3189
I am trying to call an array but it is not being called through a method.
1
Expert's answer
2011-06-20T11:50:17-0400
Your method must be like this:

void /*or any other type of return data*/ your_method_name(int* a /*and if you need other input data*/) {
// a - it's input array (pointer for first element in array)
// working wit array (for example your array will contain data {3, 2, 1, 0} ):
cout<<(*a)<<endl;
//outpun number wiil be 3, because *a it's pointer for first element in array
cout<<(*(a+1))<<endl;
//outpun number wiil be 2, because *(a+1) it's pointer for second element in array
cout<<(*(a+2))<<endl;
//outpun number wiil be 1, because *(a+2) it's pointer for third element in array
cout<<(*(a+3))<<endl;
//outpun number wiil be 0, because *(a+3) it's pointer for fourth element in array
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS