Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- template <class t>
- void print (t data){
- cout <<"the given data is "<<data<<endl;
- }
- template <class t1>
- void print(t1 data, int x){
- t1 i;
- for (i=1;i<=x;i++){
- cout << "the given data is " << data << endl;
- }
- }
- int main(){
- print(2);
- print(3.5);
- print(12345);
- print(2,10);
- print(1.5,5);
- print(12345,5);
- return (0);
- }
- #include <iostream>
- using namespace std;
- template <class tem>
- void swaap(tem &a, tem &b){
- tem t=a;
- a=b;
- b=t;
- }
- int main(){
- int x,y;
- cin>>x>>y;
- swaap(x,y);
- cout<<"Int value of x="<<x<<"y= "<<y<<endl;
- float x1,y1;
- cin>>x1>>y1;
- swaap(x1,y1);
- cout<<"Float value of x1="<<x1<<y1<<endl;
- long x2,y2;
- cin>>x2>>y2;
- swaap(x2,y2);
- cout<<"Long value of x2="<<x2<<"y2= "<<y2;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement