Skip to content

Instantly share code, notes, and snippets.

@nalin-adh
Created November 10, 2015 16:49
Show Gist options
  • Save nalin-adh/264ef1fea16d08dbb91b to your computer and use it in GitHub Desktop.
Save nalin-adh/264ef1fea16d08dbb91b to your computer and use it in GitHub Desktop.
A C++ program to swap two character data using function.
#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