#include<stdio.h>
#include<conio.h>
int main()
{
// Declaring variable a, b for two values, swap to interchange value
int a, b, swap;
// Declaring pointer that holds address of two values
int *c, *d;
// Storing address
c=&a;
d=&b;
// Inputing values
printf("Enter first value a : ");
scanf("%d",&a);
printf("Enter second value b : ");
scanf("%d",&b);
// Printing original value
printf("Original value : a = %d, b = %d\n",a, b);
// Interchanging value
swap=*c;
*c=*d;
*d=swap;
// Printing interchanged value
printf("Interchanged value : a = %d, b = %d ",a, b);
getch();
return 0;
}
c++ programming tutorials | education | education international | university | TOP WORLD UNIVERSITY 2014 |education wold
Tuesday, 4 February 2014
Program to interchange two values using pointers(swaping value)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment