answer.
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
Paha777 [63]
1 year ago
12

Write a function named max that accepts two integer values as arguments and returns the value that is the greater of the two. Fo

r example, if 7 and 12 are passed as arguments to the function, the function should return 12. Use the function in a program that prompts the user to enter two integer values. The program should display the value that is the greater of the two
Computers and Technology
1 answer:
RoseWind [281]1 year ago
6 0

Answer:

The solution code is written in Python

  1. def max(a, b):
  2.    if(a > b):
  3.        return a  
  4.    else:
  5.        return b
  6. num1 = int(input("Please input the first number: "))
  7. num2 = int(input("Please input the second number: "))
  8. print(max(num1, num2))

Explanation:

Firstly create a function max that accepts two input, a and b, as required by question (Line 1). In the function, create if statement to check if a greater than b return a and vice versa (Line 2 -5).

In the main program (Line 7 - 10), prompt user to input two numbers (Line 7 - 8). At last call the function by passing num1 and num2 as arguments and print the result (Line 10).

You might be interested in
Declare a struct named PatientData that contains two integer data members named heightInches and weightPounds. Sample output for
boyakko [2]

Answer:

struct PatientData{

   int heightInches, weightPounds;

};

Explanation:

In order to declare the required struct in the question, you need to type the keyword <em>struct</em>, then the name of the struct - <em>PatientData</em>, <em>opening curly brace</em>, data members - <em>int heightInches, weightPounds;</em>, <em>closing curly brace</em> and <em>a semicolon</em> at the end.

Note that since the object - lunaLovegood, is declared in the main function, we do not need to declare it in the struct. However, if it was not declared in the main, then we would need to write <em>lunaLovegood</em> between the closing curly brace and the semicolon.

8 0
2 years ago
Frequency of failure and network recovery time after a failure are measures of the _______ of a network.
coldgirl [10]
Frequency of a failure and network recovery time after a failure are measures of the Reliability of a network
8 0
1 year ago
1. Write a set of routines for implementing several stacks and queues within a single array. Hint: Look at the lecture material
JulsSmile [24]

Answer:

Out of the two methods The 2nd method is a better option for implementing several stacks and arrays using the single array system this is because Method 2 makes efficient use of the available space

Explanation:

A) Method 1 ( Divide the given single array in the size of n/k.)

  • How to use method 1 to implement several stacks involves :

i)  To implement several stacks through an array (x) is by dividing the array in n/k parts.

ii) The k represents the slots in which the different stacks will be placed and the n represents the size of the array x.

iii) If you need to implement at least two stacks place the first stack in the slot of a [0] to a [n/k - 1], and another stack in the slot of a[n/k] to a[2n/k-1].

note: The  disadvantage of this method is that the use of the space of the array is not much efficient. therefore method 2 is better

  • How to use method 1 to implement queues involves :

i) queues can also be implemented through an array. applying the same method above

ii) Divide the array in slots and place the queues in that slots.

This method has a problem with  the efficient utilization of the space.therefore method 2 is preferred

B) Method 2 ( uses the space efficiently ) uses two more arrays to implement stacks which are : Top_array and Next_array

  • how to use method 2 to implement several stacks

i) Store the indexes of the next item that will also be stored in all stacks in this initial stack

ii)The initial actual array is x[] and this will store the stacks.

iii)Simultaneously with several stacks, the stack which contain the free slots in the array x[] will also be maintained.

iv)  The entries of the Top_array[] will be initialized to -1. This implies that all the stacks are empty.

v)  Firstly the entries of the array Next_array[i] will be initialized to i+1, since all the slots initially are free and are pointed to the next slot.

vi) Initialize The top of the free stack that is maintaining the free slots  as 0.

vii)  The complexity of push () (method to insert an element) and pop () (method to delete an element) operations by using this method is O (1).

  • How to use method 2 to implement several queues

The same method applicable to implementing several stacks is used here but with a difference is the presence of three extra arrays which are :

Front_array[] = indicates the number of queues. This array stores the indexes of the front elements of the stacks.

Rear_array[] = determines the sizeof the array k . This array stores the indexes of the last elements of the stacks.

Next_array[] = The array n indicates the size of the single array say x. This array stores the indexes of the next items that is being pushed.

i) The initial actual array is a[] which will store the queues. The free slots will also be maintained.

ii)The entries of the Front_array[] will be initialized to -1. This means  that all the queues are empty initially

ii) Initially the entries of the array Next_array[i] will be initialized to i+1, since all the slots initially are free and are pointed to the next slot.

iv) Apply The complexity of enqueue ()  and dequeue ()  by using this method is O (1).

4 0
2 years ago
George has to present the goals of information management to his team member. What is a goal of information management? The goal
Law Incorporation [45]

Answer:

The purpose of information management is to: design, develop, manage, and use information with insight and innovation. support decision making and create value for individuals, organizations, communities, and societies.

Explanation:

5 0
1 year ago
Write a program that defines a type for a structure that stores information on a student in ENG EK 125. Declare two variables to
Mashcka [7]

Answer:

Following are the program in the C Programming Language.

#include<stdio.h> //header file

#include<string.h> //header file

struct student//creating structure

{

 //set integer variables

int marks;

int roll;

};

//define function

void initial(struct student *stu)

{

 //set integer type variables

int marks=420;

int roll_no=45,i;

stu->marks=marks;//assigning the values

stu->roll=roll_no;//assigning the values

}

//define main method to call the function

int main()

{

struct student stu;

initial(&stu);//calling the function

printf("Total marks : %d\n",stu.marks); //print output

printf("Roll No. : %d\n",stu.roll); //print output

return 0;

}

<u>Output:</u>

Total marks : 420

Roll No. : 45

Explanation:

Here, we define the structure "student" with a struct keyword for creating a structure.

  • inside the structure, we set two integer type variable "marks", "roll".

Then, we define a function "initial()" and pass an argument in the parameter of the function.

  • inside the function, we set two integer type variable "marks", "roll_no" and assign the value in the variable "marks" to 420 and variable "roll_no" to 45.
  • Assign the value in the structure's integer variables from the function's variable.

Finally, we set the main method inside it we call the function "initial()" and pass the value and then, we print the output with message.

8 0
2 years ago
Other questions:
  • In an ethernet network, the signal that is sent to indicate a signal collision is called a ________ signal.
    7·1 answer
  • What kind of device can monitor a connection at the demarc but cannot interpret data?
    9·1 answer
  • Given: an int variable k, an int array current Members that has been declared and initialized, an int variable memberID that has
    11·1 answer
  • Assume the input data is structured as follows: first there is a non-negative integer specifying the number of employee timeshee
    9·1 answer
  • // This pseudocode is intended to determine whether students have
    5·1 answer
  • Which of the registration patterns is best suited for complex architecture? A. Client side discovery pattern B. Third party regi
    13·1 answer
  • You have configured your firewall to authenticate a group of 100 users who are in your company. You set up the database of users
    14·1 answer
  • Our new catalog contains an eclectic collection of items
    6·1 answer
  • Look at the following array definition:
    11·1 answer
  • Write a function named shout. The function should accept a string argument and display it in uppercase with an exclamation mark
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!