Skip to main content

Swapping values of two variables with each other

#include<stdio.h>
#include<conio.h>
{
clrscr();
int a=10,b=5;
printf("\nBefore swapping a=%d",a);
printf("\t b=%d",b);
int temp=a;
a=b;
b=temp;
printf("\nAfter swapping a=%d",a);
printf("\t b=%d",b);
getch();
}

Comments

Popular posts from this blog

Reversing digits of a number

#include<stdio.h> #include<conio.h> void main() { clrscr(); int ,num,rev=0,rem; printf("Enter the number:"); scanf("%d",&num); while(num!=0) { rem=num%10; rev=rev*10+rem; num=num/10; } printf("Reverse of given Number is:%d",rev); getch(); }