1. What will be the output of each of the following program when it is executed. (a) #include using namespace std; template > T sum (T array[3][3], int n) { T temp = 0; for (int i =0; i for (int j =...




1. What will be the output of each of the following program when it is executed. (a)


#include using namespace std;


template > T sum (T array[3][3], int n)


{


T temp = 0;


for (int i =0; i<=>


for (int j = 0; j <=>


return(temp);


}




int main()


{


int n = 3, sum1; oat sum2;


static int a[3][3] = {{1,2,3},


{4,5,6},


{7,8,9}


};


static double b[3][3] = {{1.1,2.2,3.3},


{4.4,5.5,6.6},


{7.7,8.8,9.9}


};
















}


(b)




sum1 = sum(a,n);


cout <><> endl; sum2 = sum(b,n);


cout <> of the oating point numbers = ” sum2; cout endl;


return 0;




#include using namespace std; template class sample {


private:


T a,b; public:


T nd_min (T a, T b);


};






template


T sample :: nd_min (T a, T b)


{


return ( a <>


}




int main()


{




























}






int a = 10, b = 20; sample obj1;


int temp1 = obj1. Nd_min(a,b);


cout <><><><><><><>


sample obj2;


double temp2 = obj2. Nd_min(x,y); cout <><><>


cout <><><>




#include using namespace std; template class abc {


private:


T value; public:


abc() {


cout <>


}


abc (int a) {


cout <>


}


abc ( oat af) {


cout “constructor with oating point \n”;


}


};


int main()


{










}



(d)




abc obj1(10);


abc<> obj2(-21.22f); return 0;




//using class template #include using namespace std; template class sample {


public :


sample ();


inline void display();


};






template sample :: sample()


{


cout <“class>


}




template


void sample :: display()


{


cout <>


}




int main()


{














}






sample obj1; sample <> obj2; sample obj3; sample obj4; return 0;




#include using namespace std; template class sample {


private:


T value; public:


sample (T n) : value (n)


{


cout


};


~sample ()


{


cout <>


}


void display ()


{


cout <><>


}


};




int main()


{


sample obj1(10);


cout <><>


return 0;


}








May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here