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