Object Orient programming lap in c ++

Source Code call by reference in C programming

#include<iostream.h>

#include<conio.h>

void swap(int &x,int &y)

{

int temp;

temp=x;

x=y;

y=temp;

cout<<"\n The value of a and b in swap fun is\t "<<x<<"\t"<<y;

}

void main()

{

int a,b;

clrscr();

cout<<"\n Enter the value of a and b:\n";

cin>>a>>b;

cout<<"\n The value of a and b before the swap fun is:\t"<<a<<"\t"<<b;

swap(a,b);

cout<<"\n\n The value of a and b after the swap fun is:\t"<<a<<"\t"<<b;

getch();

}

OUTPUT Call by Reference Programming algorithm

Enter the value of a and b:

4

3

The value of a and b before the swap fun is:4 3

The value of a and b in swap fun is: 3 4

The value of a and b after the swap fun is:4 3

Source Code call by reference in C programming

#include<iostream.h>

#include<conio.h>

void swap(int &x,int &y)

{

int temp;

temp=x;

x=y;

y=temp;

cout<<"\n The value of a and b in swap fun is\t "<<x<<"\t"<<y;

}

void main()

{

int a,b;

clrscr();

cout<<"\n Enter the value of a and b:\n";

cin>>a>>b;

cout<<"\n The value of a and b before the swap fun is:\t"<<a<<"\t"<<b;

swap(a,b);

cout<<"\n\n The value of a and b after the swap fun is:\t"<<a<<"\t"<<b;

getch();

}

OUTPUT Call by Reference Programming algorithm

Enter the value of a and b:

4

3

The value of a and b before the swap fun is:4 3

The value of a and b in swap fun is: 3 4

The value of a and b after the swap fun is:4 3

## No comments:

Write comments