-
What is the output of this program?
#include <iostream>
using namespace std;
template<typename T>
void loopIt(T p)
{
int n = 2;
T value[n];
for (int k=0; k < n; k++)
{
value[k] = p++;
cout << value[k] << endl;
}
};
int main()
{
float q = 4.25;
loopIt(q);
}
-
- 10.5
11.5 - 10.5
- 11.5
- 11.5
10.5 - None of these
- 10.5
Correct Option: A
In this program, We are using the non-type template parameter to increment the value in the function template.