ProAnswers.org

Write a C program to add two numbers through variables and their pointers?

#include

#include 

void main() 

{ 

int a,b,c,d,*ap,*bp; 

clrscr(); 

printf(“Enter two numbers:”); 

scanf(“%d%d”, &a,&b); 

ap=&a; 

bp=&b; 

c=a+b; 

d=*ap+*bp; 

printf(“

sum of A &B using variable:%d”,c);

printf(“

sum of A &B using pointer:%d”,d);

getch(); 

} 

Output: 

Enter two numbers: 8 4 

Sum of a & B using variable:12 

Sum of a & B using pointer:12