learn_code_with_me();

Monday, May 20, 2013

Swapping two numbers - C Variables

by Anouar 0 comments

Tag


Share this post:

Swapping two numbers using temporary variable.
#include <stdio.h>

int main () {
	int a,b,temp;
	printf("Enter the numbers");
	printf("\nEnter the Value of A: ");
	scanf("%d",&a);
	printf("Enter the Value of B: ");
	scanf("%d",&b);
	printf("\n Before Swapping the values of A and B are A = %d B = %d",a,b);
	
	temp=a;
	a=b;
	b=temp;
		
	printf("\n After Swapping the values of A and B are A = %d B = %d",a,b);
return 0;
}

The output:

Comments 0 comments

Anouar Rahil
A newbie programmer, Blogger, Net Surfing.
anouar.r@live.com

Subscribe feeds via e-mail
Subscribe in your preferred RSS reader

Subscribe feeds rss Recent Entries

Advertise on this site Sponsored links

Categories

Popular Posts

My Photos on flick r

Subscribe feeds rss Recent Comments

Technorati

Technorati
My authority on technorati
Add this blog to your faves