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
Katyanochek1 [597]
2 years ago
12

1 #include 2 3 int max2(int x, int y) { 4 int result = y; 5 if (x > y) { 6 result = x; 7 } 8 return result; 9 } 10 11 int max

3(int x, int y, int z) { 12 return max2(max2(x,y),z); 13 } 14 15 int main() { 16 int a = 5, b = 7, c = 3; 17 18 printf("%d\n",max3(a, b, c)); 19 20 printf("\n\n"); 21 return 0; 22 } What number is printed when the program is run?
Computers and Technology
1 answer:
Serhud [2]2 years ago
6 0

Answer:

7

Explanation:

#include <stdio.h>

int max2(int x, int y) {

   int result = y;

   if (x > y) {

       result = x;

   }

   return result;

}

int max3(int x, int y, int z) {

   return max2(max2(x,y),z);

}

int main() {

   int a = 5, b = 7, c = 3;

   printf("%d",max3(a, b, c));

   printf("");

   return 0;

}

Hi, first of all, next time you post the question, it would be nice to copy and paste like above. This will help us to read the code easily. Thanks for your cooperation.

We start from the main function:

The variables are initialized → a = 5, b = 7, c = 3

max3 function is called with previous variables and the result is printed → printf("%d",max3(a, b, c));

We go to the max3 function:

It takes 3 integers as parameters and returns the result of → max2(max2(x,y),z)

Note that max2 function is called two times here (One call is in another call actually. That is why we need to first evaluate the inner one and use the result of that as first parameter for the outer call)

We go to the max2 function:

It takes 2 integers as parameters. If the first one is greater than the second one, it returns first one. Otherwise, it returns the second one.

First we deal with the inner call. max2(x,y) is max2(5,7) and the it returns 7.

Now, we need to take care the outer call max2(7, z) is max2(7, 3) and it returns 7 again.

Thus, the program prints 7.

You might be interested in
OSI is a seven-layered framework used to help define and organize the responsibilities of protocols used for network communicati
sergejj [24]

Answer:

True.

Explanation:

OSI network model is a networking framework that has seven layers that describes the encapsulation and communication of devices in a network. The seven OSI model layers are, application, presentation, session, transport, network, data-link and physical layer.

Each layer in this model describes the protocol datagram unit PDU and identifies several standard and proprietary protocols that can be used in a layer.

A network administrator of engineer can decide to use a protocol based on his choice and the brand of network device used.

8 0
3 years ago
The small company where you work needs to implement a second server for its accounting system, but does not have the funds to pu
masya89 [10]

Answer:

b. use virtualization

4 0
3 years ago
___________ is related to mass, but also includes the gravitational pull of the Earth.
anygoal [31]
Earth's gravity comes from all its mass. All its mass makes a combined gravitational pull on all the mass in your body. That's what gives you weight. And if you were on a planet with less mass than Earth, you would weigh less than you do here. So weight is the answer
4 0
3 years ago
You have this code in your program.
earnstyle [38]

The line code will create array is G = array('f',[2.5, 3, 7.4])

<h3>What is meant by array ?</h3>

As opposed to defining distinct variables for each value, arrays are used to hold numerous values in a single variable. Set the data type (such as int) and the array name, followed by square brackets [, to construct an array.

An array is a collection of elements with the same type that are kept in nearby memory  locations and may each be separately referred to using an index to a special identifier. There is no need to declare five distinct variables when declaring an array of five int values (each with its own identifier).

In the C programming language, arrays are a derived data type that may contain primitive data types like int, char, double, float, etc.

To learn more about array refer to :

brainly.com/question/28061186

#SPJ1

6 0
9 months ago
What is the difference between second generation and third generation​
Eduardwww [97]

These were later renamed to "Specialized Technology" and "Simscape Components" to help explain this difference.

Specialized Technology (Second Generation) is a Simulink based library and has been around for longer. It can still connect to Simscape, but in the same way you can connect Simulink models to Simscape -- that is, you need converters and sometimes to break algebraic loops, etc. It also has more dedicated electrical power systems capabilities. If your model will be only power systems, and especially if it's a larger model, I'd recommend this one.

Simscape Components (Third Generation) is built using the Simscape language and therefore connects directly with other Simscape blocks. If you plan to use other Simscape domains like mechanical, hydraulic, etc. I'd recommend this one.

4 0
2 years ago
Other questions:
  • WHICH OF THE FOLLOWING LOOKS JUST LIKE A CD ROM BUT CAN STORE MUCH MORE INFORMATION
    8·2 answers
  • What are the principal cybersecurity threats, both internal and external, and the principal safeguards that have been developed
    13·1 answer
  • write a program that asks the user to enter a positive integer, then prints a list of all positive integers that divide that num
    6·1 answer
  • The company where Derek works has tasked him with setting up and securing a SOHO router. He wants to make sure the wireless netw
    7·1 answer
  • Define a constructor as indicated. Sample output for below program:Year: 0, VIN: -1Year: 2009, VIN: 444555666// ===== Code from
    8·1 answer
  • Explain the computer according to size​
    10·1 answer
  • Hi I need help with an assignment. We're learning about encryption and decryption in code.org. i need help with three of the tex
    14·1 answer
  • A _____ can be used to create and test prototypes, develop interfaces, and simulate factory layouts and assembly lines, without
    10·1 answer
  • Explain ONE negative outcomes of not matching an ICT product to the correct audience:
    15·1 answer
  • Give an example of what Artificial Intelligence application most popular is used on a daily basis.
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!