Breaking News

Photo in News

Swap values of variable- c Program


/*
Developed by deepak anand.
For more programs,
visit programming-stuff-4-u.blogspot.in
*/
//This program will swap two numbers using 3rd variable
#include<stdio.h>
#include<conio.h>
void main()
{

int a,b,temp;
clrscr();
printf("Enter the values of a and b");
printf("\n");
scanf("%d %d",&a,&b);
printf("\n Values before swapping \n");
printf("a=%d \n",a);
printf("b=%d",b);
//Logic part
temp=a;
a=b;
b=temp;
printf("\n Values after swapping \n");
printf("a=%d \n",a);
printf("b=%d",b);
getch();
}



Output:
Enter the values of a and b 12
10
Values before swapping
a=12
b=10
Values after swapping
a=10
b=12




Source code: Download

No comments:

Total Pageviews

  • Posts
  • Comments
  • Pageviews
Designed By Blogger Templates