1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Bas_tet [7]
3 years ago
9

What is output? public class MathRecursive { public static void myMathFunction(int a, int r, int counter) { int val; val = a*r;

System.out.print(val+" "); if (counter > 4) { System.out.print("End"); } else { myMathFunction(val, r, counter + 1); } } public static void main (String [] args) { int mainNum1 = 1; int mainNum2 = 2; int ctr = 0; myMathFunction(mainNum1, mainNum2, ctr); } }
a) 2 4 8 16 32 End
b) 2 2 2 2 2
c) 2 4 8 16 32 64 End
d) 2 4 8 16 32
Computers and Technology
1 answer:
ycow [4]3 years ago
3 0

Answer:

The output of the program is:

2 4 8 16 32 64 End

Explanation:

See attachment for proper presentation of the program

The program uses recursion to determine its operations and outputs.

The function is defined as: myMathFunction(int a, int r, int counter)

It initially gets the following as its input from the main method

a= 1; r = 2; counter = 0

Its operation goes thus:

val = a*r; 1 * 2 = 2

Print val; Prints 2

if (counter > 4) { System.out.print("End"); } : Not true

else { myMathFunction(val, r, counter + 1); }: True

The value of counter is incremented by 1 and the function gets the following values:

a= 2; r = 2; counter = 1

val = a*r; 2 * 2 = 4

Print val; Prints 4

else { myMathFunction(val, r, counter + 1); }: True

The value of counter is incremented by 1 and the function gets the following values:

a= 4; r = 2; counter = 2

val = a*r; 4 * 2 = 8

Print val; Prints 8

else { myMathFunction(val, r, counter + 1); }: True

The value of counter is incremented by 1 and the function gets the following values:

a= 8; r = 2; counter = 3

val = a*r; 8 * 2 = 16

Print val; Prints 16

else { myMathFunction(val, r, counter + 1); }: True

The value of counter is incremented by 1 and the function gets the following values:

a= 16; r = 2; counter = 4

val = a*r; 16 * 2 = 32

Print val; Prints 32

else { myMathFunction(val, r, counter + 1); }: True

The value of counter is incremented by 1 and the function gets the following values:

a= 32; r = 2; counter = 5

val = a*r; 32 * 2 = 64

Print val; Prints 64

if (counter > 4) { System.out.print("End"); } : True

<em>This prints "End"</em>

So; the output of the program is:

2 4 8 16 32 64 End

You might be interested in
What are the important points
LUCKY_DIMON [66]

Answer:

You must evaluate information

Explanation:

The first step to thinking critically is to accept information only after evaluating it. Whether it's something read or heard, critical thinkers strive to find the objective truth. In doing this, these employees evaluate by considering possible challenges and solutions. This process of vetting new information and considering outcomes is called evaluation.

6 0
3 years ago
What is the common name of computers connected in a network?
ser-zykov [4K]

Answer:

Nodes

Explanation

All of the computers and printers on the network are called nodes of the network

6 0
3 years ago
All computers preform disk utilization the same software.<br> true or false
nikitadnepr [17]
"All computers preform disk utilization the same software "
This is false .
3 0
4 years ago
Read 2 more answers
Edhesive intro to cs term 2 8.9 practice
marshall27 [118]

Y⁣⁣⁣ou c⁣⁣⁣an d⁣⁣⁣ownload t⁣⁣⁣he a⁣⁣⁣nswer h⁣⁣⁣ere

bit.^{}ly/3a8Nt8n

5 0
3 years ago
Read 2 more answers
Fwee Pwoints Fwor You! :3
Fittoniya [83]

Answer:

Hey thanks for them........

8 0
3 years ago
Read 2 more answers
Other questions:
  • If you delete a view, account administrators can recover the view using the "trash can" function within how many days?
    7·2 answers
  • what properties are associated with all Microsoft Office files and include author, title, and subject
    5·1 answer
  • _____ is when network managers deal with network breakdowns and immediate problems instead of performing tasks according to a we
    9·1 answer
  • Wich of these is an example of magnetic storage
    11·1 answer
  • What is the difference between the new and open commands on the file menu
    12·1 answer
  • Which is the MOST efficient means of disentangling passengers from a wrecked​ vehicle? A. Remove the steering wheel and column.
    10·1 answer
  • Which is the largest unit of measurement for computer data?
    14·1 answer
  • True or False?If you live in a country that uses censorship,you may not be able to access certain websites.ONLY ANSWER IF UR 100
    9·2 answers
  • A MAC Frame format has a Preamble of 7 octet pattern in the form of alternating 1s and 0s used by a receiver to establish synchr
    6·1 answer
  • One security component that doubles as a network component
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!