
Pointers II-207
Arithmetic operations with pointers
8. Use pointers and display addition of two numbers with and without pointers
#include <stdio.h>
#include <conio.h>
void main()
{
int a=5,b=7,c,d,*ap,*bp;
clrscr();
ap=&a;
bp=&b;
c=a+b;
d=*ap+*bp;
printf("\n Sum of A & B : %d",c);
printf("\n Sum of A & B : %d",d);
}
OUTPUT:
Sum of A and B : 12
Sum of A and B : 12
void main()
{
char *c="India";
char *p ="Bharat";
char *k;
k=p;
p=c;
clrscr();
printf("%s",p);
printf(" %s",k);
}
OUTPUT:
India Bharat
M09_ITL-ESL4791_02_SE_C09.indd 207 12/22/2012 5:04:03 PM