Course Content
History of C Language
0/2
Basic Structure of C Program
0/1
Types of Errors
0/1
Language Fundamentals
0/1
Data Types and Modifiers
0/1
Programming with C Language
About Lesson

Pointer Arithmetic

A pointer in c is an address, which is a numeric value. Therefore, you can perform arithmetic operations on a pointer just as you can on a numeric value. There are four arithmetic operators that can be used on pointers: ++, –, +, and –

#include

void main()

{

    int a=10;

    int *pa;

    pa=&a;

    printf(“address stored in pa is %d”,pa);

    printf(“nvalue referring by pa is %d”,*pa);

    pa++;

    printf(“nn”);

    printf(“address stored in pa is %d”,pa);

    printf(“nvalue referring by pa is %d”,*pa);

    pa=pa+2;

    printf(“nn”);

    printf(“address stored in pa is %d”,pa);

    printf(“nvalue referring by pa is %d”,*pa);

}

 

You cannot copy content of this page