C Program to Swap Two Number
#include<stdio.h>
#include<conio.h>
void main()
{
int first, second, third;
printf("Enter first number: ");
scanf("%d", &first);
printf("Enter second number: ");
scanf("%d", &second);
// Value of first is assigned to third
third = first;
// Value of second is assigned to first
first = second;
// Value of third(initial value of first) is assigned to second
second = third;
printf("\nAfter swapping, first Number = %d\n", first);
printf("After swapping, second Number = %d", second);
getch();
}
No comments:
Post a Comment
for more information please share like comment and subscribe