Question: Need help with these C++ programs: Part 2: What is output by the following? Assume the necessary header files are included. 1. void f1(void); void

Need help with these C++ programs:

Part 2:

What is output by the following? Assume the necessary header files are included.

1. void f1(void);

void f2(void);

void main(void) {

cout << 'A';

f1();

f2();

}

void f1(void) {

f2();

cout << 'B';

}

void f2(void) {

cout << 'C';

}

2. void f1(int);

void f2(int, int);

void main(void) {

int x=5, y=2;

f1(x+y);

cout << endl << x << "+" << y << "=";

f2(x, y);

cout << endl;

}

void f1(int a) {

cout << a + 3 << " = ";

f2(a, 3);

}

void f2(int b, int c) {

cout << b + c;

}

3. int f1(int, int);

bool f2(int, int);

void main(void) {

int x=5, y=2;

cout << f1(x, y) << endl;

if(f2(5, x))

cout << "<=";

else

cout << ">";

}

int f1(int a, int b) {

return a + b;

}

bool f2(int b, int c) {

if(b < c)

return true;

else if (b > c)

return false;

return true;

}

4. int f1(int, int);

void main(void) {

int x=2, y=3;

cout << f1(x, y);

}

int f1(int a, int b) {

int i, j, cnt=0;

for(i=1; i<=a; i++) {

for(j=1; j<=b; j++) {

cout << "*";

cnt++;

}

cout << endl;

}

return cnt;

}

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!