swap using function template in c 2b 2b

Solutions on MaxInterview for swap using function template in c 2b 2b by the best coders in the world

showing results for - "swap using function template in c 2b 2b"
Amos
04 Sep 2019
1#include <bits/stdc++.h>
2using namespace std;
3template<class T , class T1>
4void excha(T &a , T1 &b){
5    T temp = a;
6    a = b;
7    b = temp;
8    
9}
10int main(){
11    // int a , b;
12    // cout<<"Enter the value of a and B "<<endl;
13    // cin>>a>>b;
14    // excha(a,b);
15    // cout<<a<<" "<<b<<endl;
16
17    // cout<<endl;
18
19    // float a , b;
20    // cout<<"Enter the value of a and B "<<endl;
21    // cin>>a>>b;
22    // excha(a,b);
23    // cout<<a<<" "<<b<<endl;
24
25    cout<<endl;
26
27    float a ;int b;
28    cout<<"Enter the value of a and B "<<endl;
29    cin>>a;
30    cin>>b;
31    excha(a,b);
32    cout<<a<<" "<<b<<endl;
33
34    return 0;
35}