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

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

Posted Date: 9/29/2012 3:52:27 AM | Location : United States







Related Discussions:- C program to swap two numbers using reference arguments, Assignment Help, Ask Question on C program to swap two numbers using reference arguments, Get Answer, Expert's Help, C program to swap two numbers using reference arguments Discussions

Write discussion on C program to swap two numbers using reference arguments
Your posts are moderated
Related Questions
Array of Objects A class is a template, which can contain data items as well as member functions to operate on the data items. Various objects of the class can also be declared

example of padovan string program

Prepare aime crossover alert expert adviso Project Description: Need to develop an expert advisor base on aime crossover alert indicator. Skills required is C Programming

program that convert take decimal digit and convert it to binart digit

Construct a console program to manage the booking of a Hotel room.

there is a pebble merchant. he sells the pebbles,that are used for shining the floor.his main duty is to take the length of the room side but he sometines mistakes doing that and m

Aim: To implement a program to maintain information of employees in an educational institute using inheritance. Code:                       class staff {

http://www.expertsmind.com/questions/decodethecode-30110560.aspx

How I get C, C++, C# .net assignments ?

Can I drop the [] while deleteing array of some built-in type (char, int, etc)? A: No. you can't Sometimes programmers think that the [] in the delete[] p only present so the