Created
November 10, 2015 16:49
-
-
Save nalin-adh/264ef1fea16d08dbb91b to your computer and use it in GitHub Desktop.
A C++ program to swap two character data using function.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<conio.h> | |
using namespace std; | |
void swap(char &,char &); | |
int main(){ | |
char ch1,ch2; | |
cout<<"Enter first character = ";cin>>ch1; | |
cout<<"Enter second character = ";cin>>ch2; | |
swap(ch1,ch2); | |
cout<<"After swapping character : "; | |
cout<<"\nNow first character = "<<ch1; | |
cout<<"\nNow second character = "<<ch2; | |
getch(); | |
return(0); | |
} | |
void swap(char &a,char &b){ | |
char temp; | |
temp=a; | |
a=b; | |
b=temp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment