C program to swap two numbers using reference arguments, C/C++ Programming

Assignment Help:

Aim: To implement a program to swap two numbers using reference arguments.

Code:

void swap(int *a, int *b)

{

            int temp;

            temp=*a;

            *a=*b;

            *b=temp;

}

void main()

{

            int a,b;

            clrscr();

            cout<<"Program to swap two variables.";

            cout<<"\nEnter variables:\nA:";

            cin>>a;

            cout<<"B:";

            cin>>b;

            swap(&a,&b);

            cout<<"\nSwapped variables:\n\nA:"<

            cout<<"\nB:"<

            getch();

}

Output:

Program to swap two variables.

Enter variables:

A:5

B:36

Swapped variables:

A:36

B:5


Related Discussions:- C program to swap two numbers using reference arguments

Project (network programming), Need help in network programming in C++ proj...

Need help in network programming in C++ project. How much you charge?

Graphic.h, what is the syntax to get a coloured output.

what is the syntax to get a coloured output.

Expression in c++, expression and its types with example programs

expression and its types with example programs

Array, Assigning value to individual elements in array

Assigning value to individual elements in array

Stone Game - Remove Last, #include int main() { int T; ...

#include int main() { int T; int N; int i; scanf("%d",&T)

Control flow, write the program to accept date and to say valid or invalid

write the program to accept date and to say valid or invalid

Algorithm , write an algorithm to swap values without using third variable

write an algorithm to swap values without using third variable

How do you access the values within an array, How do you access the values ...

How do you access the values within an array? - Arrays comprise a number of elements, which depends on the size you assigned it during variable declaration. - Every element

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd