Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following program: #include using namespace std; int f ( int a, int &b, char &c) { 1. int result; 2. if (c ==

Consider the following program:

#include

using namespace std;

int f ( int a, int &b, char &c) {

1. int result;

2. if (c == a) {

3. a = a+(++b);

4. result = b;

5. } else if (c == s) {

6. b = b*(a++);

7. result = a - b;

8. } else {

  1. c = ?;
  2. result = --b;

11. }

12. return result;

}

void main() {

13. int x = 2, y = 4, z;

14. char ca = a;

15. z = f(x, y, ca);

16. cout << x = << x, y = << y << z = << z << ca = << ca << endl;

17 ca = s;

18. {

19. int x=3, z = -2;

20. x = calc (z, y, ca);

21. cout << x = << x, y = << y << z = << z << ca = <

22. }

23. cout << x = << x, y = << y << z = << z << ca = << ca << endl;

24. ca = a;

25. z = calc(x, y, ca);

26. cout << x = << x, y = << y << z = << z << ca = << ca << endl;

27. ca = d;

28. x = calc (x, z, ca);

29. cout << x = << x, y = << y << z = << z << ca = << ca << endl;

}

  1. What are the input and output parameters to the function f?
  2. Trace the program above, by showing the sequence of lines and the number of the line, to be executed and the result of executing those specific lines.(e.g. line 11: a+b=c, line 12. result of c. etc.) Thanks

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago