Vivekananda College of Engineering and Technology
Department of Electronics & Communication Engineering
Back to Experiments
Experiment 11
C Programming Lab
Aim
To add two numbers using pointers.
Algorithm
1. Read two numbers. 2. Use pointers to add them.
Use or Edit the given C template
#include <stdio.h> int main() { int a, b, sum; int *p1, *p2; printf("Enter two numbers: "); scanf("%d %d", &a, &b); p1 = &a; p2 = &b; sum = *p1 + *p2; printf("Sum = %d", sum); return 0; }
Input data
Compile & Run
Output
Output will appear here after compilation.
C Programming Virtual Lab - Experiment 11