Congratulations to all the winners of April 2013, they have won INR 3400 cash and INR 20147 worth prizes !
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 18187 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > C# > Call by reference ( Example ) ...
Ranjeet_8

Call by reference ( Example )

 Code Snippet posted by: Ranjeet_8 | Posted on: 1/31/2013 | Category: C# Codes | Views: 407 | Status: [Member] | Points: 40 | Alert Moderator   


Call by reference:
void swap(int *x, int *y)


{
int temp;
temp = *x;
*x = *y;
*y = temp;
printf("Swapped values are a = %d and b = %d", *x, *y);
}
void main()
{
int a = 7, b = 4;
swap(&a, &b);
printf("Original values are a = %d and b = %d",a,b);
printf("The values after swap are a = %d and b = %d",a,b);
}

Output:
Original Values are a = 7 and b = 4
Swapped values are a = 4 and b = 7

Found interesting? Add this to:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/20/2013 4:58:08 AM