W.A.P. C++

WAP | CPP | Programs in C++ | C++ Solutions

Snehil Khanor's Binary Log

write a program to swap two numbers using a third variable


Two numbers are taken from the user and then swapped using a third variable.
Select To use this code as it is.. select and copy paste this code into code.cpp file :)
  1. #include<iostream.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. int a,b,c;
  7. cout<<"Enter a: ";
  8. cin>>a;
  9. cout<<"Enter b: ";
  10. cin>>b;
  11. cout<<"Before swapping:"<<endl;
  12. cout<<"a: "<<a<<" b: "<<b<<endl;
  13. //Coding by: Snehil Khanor
  14. //http://WapCPP.blogspot.com
  15. c=a;
  16. a=b;
  17. b=c;
  18. cout<<"After swapping:"<<endl;
  19. cout<<"a: "<<a<<" b: "<<b;
  20. getch();
  21. }

1 comments:

Anonymous November 6, 2014 at 6:09 PM  

Have you checked this Write a program to Swap two variables or number.One can find almost all the methods of swapping of two numbers.

Search

About WAP C++

Here you'll find a wide range of programs' solution ranging from beginer level to advanced level.
All programs here are made, compiled and tested by me..and are running absolutely fine.. still if you find any bug in any program do let me know :)

Followers

Subscribe via email

Enter your email address:

Delivered by FeedBurner

my Binary Log

Blog Archive



eXTReMe Tracker