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
statuscvo [17]
3 years ago
6

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

For 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
2 answers:
lesya692 [45]3 years ago
4 0

Answer:

#section 1

def max(int1, int2):

   if a > b:

       return a

   else:

       return b

#section 2

print("------Enter Two Integers----------\n\n")

a = int(input('Enter First Integer:'))

b = int(input('Enter Second Integer'))

print(max(a, b))

Explanation:

The programming language used is python 3.

#section 1

The function is defined and it has two parameters (int1 and int2) that allows it to take two arguments.

The IF and ELSE statements compares both parameters and return the highest.

#section 2

A program is written to prompt the user for two inputs, and converts them to an integer, passes it to the max function and prints the result to the screen

Artyom0805 [142]3 years ago
3 0

// writing c++ function

int maximum ( int a , int b){

if(a>b)

return a;

else

return b;

}

//when this function will be called it will return the max of the integers sent.

//for example

int max = maximum ( 3,4)

//max variable will have 4 returned by the function

You might be interested in
Write a program that will predict the size of a population of organisms. The program should ask the user for the starting number
sineoko [7]

Answer:

// using c++ language

#include "stdafx.h";

#include <iostream>

#include<cmath>

using namespace std;

//start

int main()

{

 //Declaration of variables in the program

 double start_organisms;

 double daily_increase;

 int days;

 double updated_organisms;

 //The user enters the number of organisms as desired

 cout << "Enter the starting number of organisms: ";

 cin >> start_organisms;

 //Validating input data

 while (start_organisms < 2)

 {

     cout << "The starting number of organisms must be at least 2.\n";

     cout << "Enter the starting number of organisms: ";

     cin >> start_organisms;

 }

 //The user enters daily input, here's where we apply the 5.2% given in question

 cout << "Enter the daily population increase: ";

 cin>> daily_increase;

 //Validating the increase

 while (daily_increase < 0)

 {

     cout << "The average daily population increase must be a positive value.\n ";

     cout << "Enter the daily population increase: ";

     cin >> daily_increase;

 }

 //The user enters number of days

 cout << "Enter the number of days: ";

 cin >> days;

 //Validating the number of days

 while (days<1)

 {

     cout << "The number of days must be at least 1.\n";

     cout << "Enter the number of days: ";

     cin >> days;

 }

 

 //Final calculation and display of results based on formulas

 for (int i = 0; i < days; i++)

 {

     updated_organisms = start_organisms + (daily_increase*start_organisms);

     cout << "On day " << i + 1 << " the population size was " << round(updated_organisms)<<"."<<"\n";

     

     start_organisms = updated_organisms;

 }

 system("pause");

  return 0;

//end

}

Explanation:

6 0
3 years ago
The weight of your car will also affect its_____.
Usimov [2.4K]

Answer: C

Explanation:

4 0
3 years ago
Read 2 more answers
What linux command displays the ip address and subnet mask?
Nookie1986 [14]
Type "ifconfig" at the terminal prompt, then press the "Enter" key. The IP address is labeled as "inet addr." The subnet is labeled as "Mask."

step 2

Type "netstat -r" at the command prompt, then press the "Enter" key to view the gateway address.

3 0
3 years ago
A student is having trouble finding enough time in his busy schedule to work on his school science project. He has a demanding s
Katena32 [7]

Answer:c

Explanation:

got it rii

3 0
3 years ago
Read 2 more answers
Convert the following C program to C++.
ki77a [65]

Answer:

The program equivalent in C++ is:

<em>#include <cstdio></em>

<em>#include <cstdlib></em>

#define SIZE 5

using namespace std;

<em>int main(int argc, char *argv[]) {</em>

<em>int numerator = 25;</em>

<em>int denominator = 10;</em>

<em>FILE * inPut = fopen(argv[1], "r");</em>

<em>FILE * outPut = fopen(argv[2], "w");</em>

<em>float result = (float)numerator/denominator;</em>

<em>fprintf(outPut,"Result is %.2f\n", result);</em>

<em>float arr[SIZE];</em>

<em>for(int i = 0; i < SIZE; i++) {</em>

<em>fscanf(inPut, "%f", &arr[i]);</em>

<em>fprintf(outPut, "%7.4f\n", arr[i]);</em>

<em>}</em>

<em>return 0;</em>

<em>}</em>

Explanation:

See attachment for explanation.

Each line were numbered with equivalent line number in the C program

Download cpp
8 0
3 years ago
Other questions:
  • How does the occupational outlook affect the monetary benefits of a career
    11·1 answer
  • Why is the stateless nature of the internet a problem for shopping cart software? g?
    5·2 answers
  • ¿Ha existido en la historia de nuestra humanidad alguien que hubiera hecho posible el sueño del ser humano en obtener energía li
    11·1 answer
  • Any one of the languages that people have designed for specific purposes, such as representing mathematical ideas or computer pr
    15·1 answer
  • The retention of encoded information over time is called storage. A measure of memory storage that involves identifying informat
    5·1 answer
  • Which method do software testers use to isolate new code from the rest of the network during the test stage of the software deve
    15·1 answer
  • Your employer is opening a new location, and the IT director has assigned you the task of calculating the subnet numbers for the
    14·1 answer
  • which feature of organisations to manage needs to know about to build and use information system successfully
    6·1 answer
  • Calcula l'energia (Kwh) consumida per una màquina de 30 CV que funciona durant 2 hores.
    12·1 answer
  • Imagine that you just received a summer job working for a computer repair shop one of your first task is to take apart a compute
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!