Write a Program in C to Add Two Numbers using Pointers

In this example, You learn about c program to add two numbers using pointers.

Here you learn addition of two pointers in c, You are given two numbers and the task of the program to find sum of two numbers using pointers.

C Program to Add Two Numbers using Pointers

#include<stdio.h>

void sum(int *p,int *q);

void main()
{
  int a, b;
  printf("Enter Two Numbers:");
  scanf("%d %d",&a,&b);
  sum(&a,&b);
}

void sum(int *p, int *q)
{
  printf("Sum of %d and %d is %d",*p,*q,*p+*q);
}

Output
Enter Two Numbers: 17  3
Sum of 17 and 3 is 20
I hope you enjoy this example if you have doubt leave it in the comment box below.
Happy Coding 😊

If you have any doubts, Please let me know

Previous Post Next Post

Contact Form