Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What I have to do in these is take the code, max(5,10) and say which coding lang

ID: 3664167 • Letter: W

Question

What I have to do in these is take the code, max(5,10) and say which coding language (java, c++, ada) will do that based off the code above it.

3. Consider the following method declarations:

int max(int x, int y);
double max(double x, double y);
int max(int x, int y, int z);

Resolve the following function/methods calls in Java, Ada, and C++:

a) max(5,10);
b) max(5.5,10.75);
c) max(5,10.5);
d) max(5,20,15);
e) max(5.5,5,10);

Answer:
1. int max(int x, int y);
2. double max(double x, double y);
3. int max(int x, int y, int z);

(a)
(b)
(c)
(d)
(e)

4. Consider the following method declarations:

int pow(int x, int y);
double pow(double x, double y);
double pow(int x, double y);

Resolve the following function/methods calls in C++, Java, and Ada:

int x; double y;

a) x = pow(2,3);
b) y = pow(2,3);
c) x = pow(2,3.2);
d) y = pow(2,3.2);
e) x = pow(2.1,3);
f) y = pow(2.1,3);
g) x = pow(2.1,3.2);
h) y = pow(2.1,3.2);

Answer:
1. int pow(int x, int y);
2. double pow(double x, double y);
3. double pow(int x, double y);

(a)
(b)
(c)
(d)
(e)
(f)
(g)
(h)

Explanation / Answer

3. Consider the following method declarations:

int max(int x, int y);
double max(double x, double y);
int max(int x, int y, int z);

Resolve the following function/methods calls in Java, Ada, and C++:

a) max(5,10);
b) max(5.5,10.75);
c) max(5,10.5);
d) max(5,20,15);
e) max(5.5,5,10);

Answer with explanation:
          a) int max(int x, int y); => both arguments x and y are integer. So it will return an integer.
           b) double max(double x, double y); => both arguments x and y are double. So it will      

return an double.
           c) double max(double x, double y); => here x is integer and y is double. To compare with

  an double value, the integer value (x) converted to double. Now both arguments are

               double. So it will return an double.
          (d) int max(int x, int y, int z); => Here all arguments x ,y and z are integers. So it will      

              return an integer.
          (e) int max(int x, int y, int z); => Here argument x is double ,y and z are integers. Normally

                arguments y and z will be converted to double. But no format is given to accept three

                number of double arguments.

               As a result, x is converted to integer . So it will return an integer.

----------------------------------------------------------------------------------------

4. Consider the following method declarations:

int pow(int x, int y);
double pow(double x, double y);
double pow(int x, double y);

Resolve the following function/methods calls in C++, Java, and Ada:

int x; double y;

a) x = pow(2,3);
b) y = pow(2,3);
c) x = pow(2,3.2);
d) y = pow(2,3.2);
e) x = pow(2.1,3);
f) y = pow(2.1,3);
g) x = pow(2.1,3.2);
h) y = pow(2.1,3.2);

Answer:

Given int x; double y;
a). int pow(int x, int y); => both arguments and return value are integer
b). double pow(double x, double y); => both arguments are integer. But return value is double. So arguments x and y becomes double
c). int pow(int x, int y); => argument x is integer , y is double but return value is integer. So y is converted to int.
(d) double pow(double x, double y); => return value is double. Argument x is converted to double. Y is double
(e) int pow(int x, int y); => return value is int. Argument x becomes integer. Y is integer
(f) double pow(double x, double y); => return value is double. X is double. Y is converted to double.
(g) int pow(int x, int y); => both arguments are double. but return value is integer. So arguments x and y becomes integer.
(h) double pow(double x, double y); both arguments are double. Also return value is double

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote