0% found this document useful (0 votes)
2K views2 pages

WAP To Swap Two Numbers Using Parameterized Constructor

This C++ program defines a class called swap that takes two integer parameters and swaps their values using a common algorithm. The main function prompts the user to input two integers, creates an instance of the swap class, passing in the integers, then prints out the swapped values before ending.

Uploaded by

9y9a
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views2 pages

WAP To Swap Two Numbers Using Parameterized Constructor

This C++ program defines a class called swap that takes two integer parameters and swaps their values using a common algorithm. The main function prompts the user to input two integers, creates an instance of the swap class, passing in the integers, then prints out the swapped values before ending.

Uploaded by

9y9a
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<iostream.h> #include<conio.

h>

int a,b; class swap { public: swap(int,int) { a=a+b; b=a-b; a=a-b; }

~swap() { cout<<"\n \t object destroyed"; }

};

int main() {

clrscr(); cout<<"enter a"<<endl; cin>>a; cout<<"enter b"<<endl; cin>>b;

{ swap a1(a,b); cout<<"a is"<<a; cout<<"b is "<<b; }

getch(); return 0;

You might also like