Sunday, 16 October 2016

HHW Q20. WAP to swap 2 nos. without using third variable .

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
cout<<"Enter first no. a = ";
cin>>a;
cout<<"Enter second no. b = ";
cin>>b;
a=a+b;
b=a-b;
a=a-b;
cout<<"a = "<<a<<"\n"<<"b = "<<b;
getch();
}

No comments:

Post a Comment

Basic Implementation of Array as a Pointer

#include<iostream.h> #include<conio.h> void main() { clrscr();   int arr[5];   cout<<"Enter 5 nos. ";   f...