ACEM PORTAL
Would you like to react to this message? Create an account in a few clicks or log in to continue.
ACEM PORTAL

::Community of ACEM students::
 
HomeHome  GalleryGallery  SearchSearch  Latest imagesLatest images  RegisterRegister  Log in  
Search
 
 

Display results as :
 
Rechercher Advanced Search
Poll
Latest topics
» Primer Imperio-Torre De Control Mp3
Swapping variables in C EmptyFri Feb 14, 2014 1:20 pm by bakakali

» LTSP Deployment
Swapping variables in C EmptySat May 09, 2009 11:31 am by Santos

» GTA SanAndreas 64kB!!!
Swapping variables in C EmptyTue May 05, 2009 2:56 pm by Santos

» EPL names..
Swapping variables in C EmptyThu Apr 30, 2009 4:26 pm by Kxhitiz

» Google logo.
Swapping variables in C EmptyThu Apr 30, 2009 4:22 pm by Kxhitiz

» Google logo.
Swapping variables in C EmptyThu Apr 30, 2009 11:36 am by Santos

» the longest website in the world haha
Swapping variables in C EmptyWed Apr 29, 2009 8:50 am by Kxhitiz

» Ubuntu 9.04 Jaunty Jackalope.
Swapping variables in C EmptySat Apr 25, 2009 12:31 am by Santos

» Program to display text with defined cursor position and defined color
Swapping variables in C EmptySat Apr 25, 2009 12:11 am by Santos

Navigation
 Portal
 Index
 Fun
 Memberlist
 Profile
 FAQ
 Search
November 2024
SunMonTueWedThuFriSat
     12
3456789
10111213141516
17181920212223
24252627282930
CalendarCalendar

 

 Swapping variables in C

Go down 
AuthorMessage
Santos

Santos


Posts : 23
Join date : 2009-03-11
Age : 37
Location : Kathmandu,Nepal

Swapping variables in C Empty
PostSubject: Swapping variables in C   Swapping variables in C EmptyThu Apr 02, 2009 10:06 am

This is a post on NNF by user viper and edited by other users.I have posted it here because I found it impressive although I haven't compiled it somebody plz. ....


normally to swap a n b you would

void swap(int a, int b)
{
int temp;

printf("val of a =%d and val of b=%d",a,b);
temp=a;
a=b;
b=temp;
printf("val of a =%d and val of b=%d",a,b);
}

u can do this without allocating the variable temp as

void swap(int a, int b)
{
printf("val of a =%d and val of b=%d",a,b);
a= a + b;
b= a - b;
a= a - b;
printf("val of a =%d and val of b=%d",a,b);
}

study
Back to top Go down
http://technoflag.blogspot.com
 
Swapping variables in C
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
ACEM PORTAL :: Programming :: C & C++-
Jump to: