Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
template
4.
T multIt(T x)
5.
{
6.
for(int ii = 0; ii < count; ii++)
7.
{
8.
x = x * x;
9.
}
10.
return x;
11.
};
12.
int main()
13.
{
14.
float xx = 2.1;
15.
cout
Options:
A .  2.1
B .  378.228
C .  2.1: 378.228
D .  None of the mentioned
Answer: Option C

In this program, We specifed the type in the template function. We need to compile this program by adding -std=c++0x.
Output:
$ g++ -std=c++0x spec1.cpp
$ a.out
2.1: 378.228



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers