C Program to add two Numbers / Integers using Pointers
C Program to add two numbers / Integers using Pointers :
PROGRAM:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#include<stdio.h> #include<conio.h> main() { int num1,num2, *p, *q, sum; // *p,*q are integer pointer variables printf("\n Enter two integers to add: "); scanf("%d %d", &num1, &num2); p = &num1; // &num1 gives the value at address of num1 q = &num2; sum = *p + *q; // adding the values of two pointer variables printf("\n Sum of entered numbers is: %d",sum); //printing sum getch(); return 0; } |
Sample Output:( using GNU GCC Compiler with Code Blocks IDE )
Enter two integers to add: 15 10
Sum of the entered numbers is: 25
YOU CAN GET A HUGE LIST OF C PROGRAMS ON http://www.vitedu.in with output and in downloadable format…. Have a Look at it…