Write c++ code to swap two number.

Write a program to swap two number in c++;

Write c++ code to swap two number.

Swapping between  two number using c++;

  
#include<iostream>
void main()
{
int d1, d2, temp;
cout<<"Enter the first number : ";
cin>>d1;
cout<<"Enter the second number : ";
cin>>d2;
temp = d1;
d1 = d2;
d2 = temp;
cout<<"The value numbers after swapping is :"<<endl;
cout<<"First no. : "<<d1<<endl;
cout<<"Second no. : "<<d2;
}

output-:
Enter the first number :10
Enter the second number :15
The value numbers after swapping is :
First no. :15
Second no. :10

No comments:

Post a Comment