Swaping two numbers with using third variable


Swaping two numbers with using third variable

#include <stdio.h>
#include <conio.h>

void main()
{
int a;
int b;
int temp;

clrscr();

printf("Enter value of a : ");
scanf("%d",&a);

printf("Enter value of b : ");
scanf("%d",&a);

printf("\nValues Before Interchange\n");

printf("\na is : %d",a);
printf("\nb is : %d",b);

temp = a ;

a = b;
b = temp;

printf("\n\nValues After Interchange\n");
printf("\na is : %d",a);
printf("\nb is : %d",b);

getch();
}

Output :

0 comments:

Post a Comment