Image

C Language - Scalar Factor - Scalar Factor

Scalar Factor

We can not multiply or divide pointer value but we can add and subtract pointers. Whenever we adding or subtracting pointer value they are manipulated as using scalar factor as shown in following ex.

Example

#include<stdio.h>
#include<conio.h> main(){
int a=5, *pi=&a;
char b='x', *pc=&b;
float c=5.5,*pf=&c;
clrscr();
printf("value of pi=Address of a=%u\n",pi);
printf("value of pc=Address of a=%u\n",pc);
printf("value of pf=Address of a=%u\n",pf);
pi++;
pc++;
pf++;
printf("now value of pi=%u\n",pi);
printf("now value of pc=%u\n",pc);
printf("now value of pf=%u\n",pf);
getch();
}