Addition using pointer

C program to add number using pointer :

code

  #include<stdio.h>

#include<conio.h>

   void main()

{

    int  num1,num2,*ptr1,*ptr2,sum;

   clrscr();

   printf(“\nEnter first number :”);

   scanf(“%d”, &num1);

  printf(“\nEnter second number”);

  scanf(“%d”,&num2);

   ptr1=num1;

  ptr2=num2;

  sum= *ptr1 + *ptr2;

  printf(“\nAddition of given number :”);

   getch();

}


output

Enter first number :

4

Enter second number :

8

Addition of given number :

12

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s