C program for addition two numbers using pointer

C program for addition two numbers using pointer:
If you are using any software then below program will not give an error, but if you are using TURBO C then you have to make some changes like: void main() and some function like clrscr() or getch().

#include<stdio.h>
main()
{
 int a,b,*ptr1,*ptr2;
 int num;

 printf("Enter two numbers : ");
 scanf("%d%d",&a,&b);

 ptr1=&a;
 ptr2=&b;

 num= *ptr1 + *ptr2;

 printf("Sum = %d", num);
}

OUTPUT:

Enter two numbers : 5 7
Sum = 12

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.