In this program, we are going to share a C program to add two numbers using Pointer. If you are a beginner and want to start learning the C programming, then keep your close attention in this tutorial as I am going to share a C program to add two numbers using Pointer with the output.
We have designed this program for beginners for learning purpose. Copy below c program and execute it with c compiler to see the output of the program.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include<stdio.h> #include<conio.h> void main() { clrscr(); int num1, num2, *ptr1, *ptr2, sum=0; printf("Enter the two number :"); scanf("%d%d",&num1,&num2); ptr1 = &num1; ptr2 = &num2; sum = *ptr1 + *ptr2; printf("Sum of the two number is %d",sum); getch(); } |
Enter the two number :1025
Sum of the two number is 35
Same program in Java programming language.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.