Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4. using namespace std;
  5.  
  6. template <class t>
  7. void print (t data){
  8.     cout <<"the given data is "<<data<<endl;
  9. }
  10.  
  11. template <class t1>
  12. void print(t1 data, int x){
  13.     t1 i;
  14.     for (i=1;i<=x;i++){
  15.         cout << "the given data is " << data << endl;
  16.     }
  17. }
  18.  
  19. int main(){
  20.     print(2);
  21.     print(3.5);
  22.     print(12345);
  23.     print(2,10);
  24.     print(1.5,5);
  25.     print(12345,5);
  26.     return (0);
  27. }
  28.  
  29.  
  30.  
  31. #include <iostream>
  32. using namespace std;
  33. template <class tem>
  34. void swaap(tem &a, tem &b){
  35.     tem t=a;
  36.     a=b;
  37.     b=t;
  38.  
  39. }
  40.  
  41. int main(){
  42.     int x,y;
  43.     cin>>x>>y;
  44.     swaap(x,y);
  45.     cout<<"Int value of x="<<x<<"y= "<<y<<endl;
  46.     float x1,y1;
  47.     cin>>x1>>y1;
  48.     swaap(x1,y1);
  49.     cout<<"Float value of x1="<<x1<<y1<<endl;
  50.     long x2,y2;
  51.     cin>>x2>>y2;
  52.     swaap(x2,y2);
  53.     cout<<"Long value of x2="<<x2<<"y2= "<<y2;
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement