What is pointer arithmetic, C/C++ Programming

Assignment Help:

Pointer Arithmetic

We can manipulate the pointers too. We can perform operations such as addition, subtraction, increment and decrement etc.,. As the pointer variables have address, adding or subtracting a number results in another address, which is at an offset from the original address. This may be memory address occupied by another variable.

e.g.

                int   i, j, k ;

                int  *iptr = &i;

                *iptr = *iptr + 2;  // I = I + 2;

                 iptr = iptr + 2 // adds 2 to address.

These are useful when using arrays.

e.g.

arr[10];

int *iptrb = &arr[0];

int *iptre = &arr[10];

While ( iptrb != iptre)

     {        

 Do something with the value if (*iptrb);

++iptrb;

}

 


Related Discussions:- What is pointer arithmetic

Switch...case, Write a function to accept a character and display it 40 tim...

Write a function to accept a character and display it 40 times.

Program, write a program that adds all numbers from 1 to 200

write a program that adds all numbers from 1 to 200

Area of curve, Write a program to find the area under the curve y = f(x) be...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Write a program that illustrate creation of a data file, Write a Program th...

Write a Program that illustrate creation of a data file? Here is a program to generate a Fibonacci series and write it into a Data file. # include main() { FILE *fpt;

Algorthrithm for c programe, Need algorithm for c programe #Minimum 100 wor...

Need algorithm for c programe #Minimum 100 words accepted#

Optimized nic driver for windows compact 7, Optimized NIC Driver for Window...

Optimized NIC Driver for Windows Compact 7 for Hard Real Time Communication Project Description: I am seeking an optimized driver (miniport driver) that will be used for sele

C++, #questAt a shop of marbles, packs of marbles are prepared. Packets are...

#questAt a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets wit

#compiler design limiting instrutions, Ravi is a newbie to the programming ...

Ravi is a newbie to the programming and while learning the programming language he came to know the following rules: · Each program must start with ''''''''{'''''''' and end wi

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd