Home / Programs / Write a program to add numbers given by the user through the use of pointers.
🚀 Programming Example

Write a program to add numbers given by the user through the use of pointers.

👁 23,846 Views
💻 Practical Program
📘 Step Learning
Write a program to add numbers given by the user through the use of pointers.

💻 Program Code

#include <stdio.h>
int main()
{
	int a,b,c;
	int *pa,*pb,*pc;
	pa=&a;
	pb=&b;
	pc=&c;
	printf("\n ENTER THE FIRST NUMBER:");
	scanf("%d",pa);
	printf("\n ENTER THE SECOND NUMBER:");
	scanf("%d",pb);
	*pc=*pa+*pb;
	printf("\n SUM IS %d",*pc);
	return 0;
}


                        

🖥 Program Output


 ENTER THE FIRST NUMBER:12

 ENTER THE SECOND NUMBER:13

 SUM IS 25

                            

📘 Explanation

None
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.