Plsss help...code(c++) problem(POINTERS)?
-
INCLUDE<IOSTREAM.H> VOID MAIN() { INT ARRAY[]={4,6,10,12}; INT*PTR=ARRAY; FOR(INT I=1;I<=3;I++) { COUT<<*POINTER<<"#" POINTER++; } COUT<<ENDL; FOR(I=1;I<=4;I++) { (*POINTER)*=3; --POINTER; //<---------THIS ONE } FOR(I=1;I<5;I++) COUT<<ARRAY[I-1]<<"@" } COUT<<ENDL; .. .. THE ANS IS COMING OUT TO BE ------> 4#6#10# 12@18@30@36@ <-------I AM HAVING DIFFICULTY IN THIS LINE SINCE IT WAS GIVEN IN THE PROGRAM "--POINTER"...HOW COME IT IS NOT POINTER ++ AGAIN.....SHOULDNT IT BE?? PLS EXPLAIN ME THIS LINE PROPERLY THANX A LOT IN ADVANCE
-
Answer:
All are upper case. Any how you are taking PTR as the pointer to the array. void main() { int array[]={4,6,10,12}; int *PTR=array; for(int i=0;i<4;i++) {cout<< *PTR<<endl; PTR++; } for(int i=0;i<4;i++) { *(PTR) *=3; --PTR; } for(int i=0;i<4;i++) cout<<array[i]<<endl; return 0; } Do remember that in C/C++ first element index is 0. Not 1.
kvothe at Yahoo! Answers Visit the source
Other answers
All are upper case. Any how you are taking PTR as the pointer to the array. void main() { int array[]={4,6,10,12}; int *PTR=array; for(int i=0;i<4;i++) {cout<< *PTR<<endl; PTR++; } for(int i=0;i<4;i++) { *(PTR) *=3; --PTR; } for(int i=0;i<4;i++) cout<<array[i]<<endl; return 0; } Do remember that in C/C++ first element index is 0. Not 1.
James Bond
Related Q & A:
- How to Convert Code from VB to C++?Best solution by Stack Overflow
- How can I convert Matlab code to c#?Best solution by Stack Overflow
- Where to find 'the art and Science of C' source code?Best solution by Stack Overflow
- Help With Ebay Problem?Best solution by Yahoo! Answers
- Help with c++ grading program.Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.