Question: what is the output, please explain the code. 1.) template void fun(const T&x) { static int count = 0; cout < < x =

what is the output, please explain the code.

1.)

template

void fun(const T&x)

{

static int count = 0;

cout << "x = " << x << count << endl;

++ count;

return;

}

int main()

{

fun (1);

cout << endl;

fun(1);

cout <

fun(1.1);

cout << endl << endl << endl;

return 0;

}

2.)

What is the ouput?

template

class Test

{

private:

T val;

public:

static int count;

Test() { count++;}

};

template

int Test::count = 0;

int main()

{

Test a;

Test b;

Testc;

cout<< Test::count <

cout<< Test::count <

return 0;

}

3.)

What is the ouput?

void f (int n )

{

for (int i = 1 ; i < n ; i++ )

cout << n * i << " " ;

cout << " ";

if (n > 1)

f(n-1);

cout<< n << " " ;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!