POINTER ARITHMETIC OPERATIONS
- · Pointers offers arithmetic operations in C-language.
- · For normal variables increment, Decrement, postfix and prefix means increment or decrement by value of 1.
- · But in pointer variables increment, decrement, postfix and prefix means increment or decrement by address of a variable.
- · Arithmetic operations applied on pointers, Not on addresses
/*
EXAMPLE PROGRAM FOR POINTER ARITHMETIC OPERATIONS */
main()
{
int *p,*q,x=20,y=10;
clrscr();
p=&x;
q=&y;
printf(“Addition=%d”, (*p) + (*q));
printf(“Substraction=%d”,(*p)-(*q));
printf(“Multiplication=%d”, (*p) * (*q));
printf(“Division=%d”,(*p)/(*q));
getch();
}
No comments:
Post a Comment