google-site-verification: googlef8aa845b858144d3.html COMPUTER SCIENCE NOTES: Swapping: (Exapmle 4) Algorithm for swapping of two numbers using pointers.

Thursday, March 2, 2017

Swapping: (Exapmle 4) Algorithm for swapping of two numbers using pointers.

/* 4 program of swap 2 number */
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,temp,*ptr1,*ptr2;
clrscr();
printf("Enter value of a and b:\n");
scanf("%d %d",&a,&b);
ptr1=&a;
ptr2=&b;

temp=*ptr1;
*ptr1=*ptr2;
*ptr2=temp;

printf("value of a is %d and value of  b is %d",a,b);
getch();
}




No comments:

Post a Comment