C-Programming Tutorials

C Program to Addition of Two Numbers using Pointer

This program performs addition of two numbers using pointers.

In this program I have used two integer variables x, y and two pointer variables p and q.

Firstly I have assign the addresses of x and y to p and q respectively and then assign the sum of x and y to variable sum. & is address of operator and * is value at address operator.


#include <stdio.h>

int main()


    int first, second, *p, *q, sum;

       printf("Enter two integers to add\n");

    scanf("%d%d", &first, &second);

       p = &first;

    q = &second;

       sum = *p + *q;

       printf("Sum of entered numbers = %d\n",sum);

   5    return 0;


C Program to Copy Files (Prev Lesson)
(Next Lesson) C Program to Delete a File
Back to C-Programming Tutorials

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!