Friday, October 28, 2016

C++(Swap The Values)

7-
Write a program to swap the values of two variables. 

#include<iostream.h>
#include<conio.h>
 
int main()
{
      int a,b,temp;
      cout<<"\nEnter two numbers : ";
      cin>>a>>b;
      temp=a;
      a=b;
      b=temp;
      cout<<"\nAfter swapping numbers are : ";
      cout<<a<<" "<<b;
 
      getch();
      return 0;
}

No comments:

Post a Comment