Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
template
4.
inline T square(T x)
5.
{
6.
T result;
7.
result = x * x;
8.
return result;
9.
};
10.
int main()
11.
{
12.
int i, ii;
13.
float x, xx;
14.
double y, yy;
15.
i = 2;
16.
x = 2.2;
17.
y = 2.2;
18.
ii = square(i);
19.
cout
Options:
A .  int
B .  float
C .  constant expression
D .  none of the mentioned
Answer: Option C

Answer:a
Explanation:
In this program, We are passing the values and calculating the square of the value by using the function template.
Output:
$ g++ ftemp4.cpp
$ a.out
2 4
2.2 4.84



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers