1)
Address of any variable can be assigned to a pointer
variable. E.g.
p=&a; q=&b ;
where p & q are pointer
variables and a & b are simple variables.
2)
Content of one Pointer can be assigned to other pointer
provided they point to same data type. E.g.
int *p, *q;
p=q;
3)
Integer data can added to or subtracted from pointer
variables.
E.g. int *p;
p+1;
4)
One pointer can be subtracted from other pointer provided
they point to elements of same array. E.g.
int a[3],*pf,*pl;
pf=a;
pl=a+2;
printf(“%p”,pl-pf);
5)
There is no sense in assigning an integer to a pointer
variable.
6)
Pointer variable can not be multiplied and added.
7)
Null value can be assigned to a pointer variable.
Passing pointer to a function
Write a program to covert
upper case letter into lower and vice versa using call by reference.
void
conversion(char *); //function prototypes
void main()
{
char input;
clrscr();
printf("Enter Character of Ur
choice\n");
scanf("%c",&input);
conversion(&input);
printf("\nThe corresponding character
is\t%c",input);
getch();
}
void
conversion(char *c)
{
if(*c>=97 && *c<=122)
*c=*c-32;
else if(*c>=65 && *c<=90)
*c=*c+32;
}
Comments
Post a Comment