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
QveST [7]
4 years ago
14

Write a function MaxMagnitude with two input parameters, that returns the largest-magnitude value. If the inputs are 5 7, the fu

nction returns 7. If the inputs are-8-2, the function returns-8. (Note: The function does not just return the largest value, which for-8-2 would be -2). Though not necessary, you may use the absolute-value built-in math function. Use the function in a program that takes two integer inputs, and outputs the largest-magnitude value.
Computers and Technology
1 answer:
irakobra [83]4 years ago
6 0

Answer:

The program to this question can be given as:

Program:

#include<stdio.h> //define header file

//#include<stdlib.h> //define header file  

#include<math.h> //define header file

int MaxMagnitude (int n1, int n2) //define function.

{

 int largest_magnitude_value= 0;

 if (abs(n1) > abs(n2))  

 {  

   // largest_magnitude_value

  largest_magnitude_value= n1;

 }

 else

 {  

   //largest_magnitude_value

   largest_magnitude_value=n2;

 }

 return largest_magnitude_value; //return value.

}

int main()  //define main function  

{

 int n1,n2,x;

 //define variable.

 printf("Enter first number :");

 //message

 scanf("%d",&n1);

 //input first value from user

 printf("Enter second number :");

//message

 scanf("%d",&n1);

    //input second value from user

 x=MaxMagnitude(n1, n2);  

//variable holds function return value

 printf("largest magnitude value  is =%d",x);

 //print value.

 return 0;

}

Output:

Enter first number : 5

Enter second number : 7

largest magnitude value is =7

Explanation:

The description of the above C program can be given as:

  • the above program firstly we define the header file in this we define the "math.h" header file that is a part of the "stdlib.h" that stands for standard library. This file includes math function, memory allocation, process control, and others.
  • Then we define a function that is "MaxMagnitude()" function.The return type of this function is int. I this function we pass two integer values that use the conditional statement to check which value is greater. In if block we use the absolute() function that returns an absolute value that holds in a variable that is "largest_magnitude_value".
  • Then we define the main function. In this, we define 3 integer variable that is n1,n2, and x. In the n1 and n2, we take value form the user and pass the value to the function in calling time and use x variable to print function return value.
You might be interested in
How long does it take to wash 12 t-shirts in the quickest way?​
Alex_Xolod [135]

Answer:

Please let me know also

3 0
3 years ago
Read 2 more answers
Consider the following recursive method. public static string recur(int val) { string dig = "" + (val % 3); if (val / 3 &gt; 0)
Oksana_A [137]

The recursive method recur executes itself from within

When the statement System.out.println(recur(32)); is executed, the string value "2101" is printed

<h3>How to determine the output of the statement?</h3>

The flow of the program is as follows:

  • The method keeps updating the string variable dig with the remainder of the val variable divided by 3
  • When the remainder is less than or equal to 0, the method is exited

So, when 32 is divided by 3.

The remainders are 2, 1, 0 and 1

So, the output of the statement is "2101"

Read about java methods at:

brainly.com/question/19271625

5 0
2 years ago
Which mechanism will move a port into a root-inconsistent state if bpdus coming from a certain direction indicate another switch
erma4kov [3.2K]

A root guard is seen as the  mechanism will move a port into a root-inconsistent state if bpdus coming from a certain direction indicate another switch is trying to become the root bridge.

<h3>What is Root guard?</h3>

Root guard is known to be a term that pertains to the family of STP feature and it is one that is enabled only on a port-by-port basis.

Note that  it hinders a configured port from changing to a root port and as such, a root guard is seen as the  mechanism will move a port into a root-inconsistent state if bpdus coming from a certain direction indicate another switch is trying to become the root bridge.

Learn more about root guard from

brainly.com/question/27780486

#SPJ1

4 0
2 years ago
Write a program that ask a user to input radius of a circle and display circumference of a circle
uranmaximum [27]

Answer:

Explanation:

8

4 0
3 years ago
Write a Python 3 program that will compute the total cost of an amazon purchase. The program should ask the user to enter the am
valentina_108 [34]

Answer:

price = float(input("Enter amount of a purchase: "))

shipping_price = 0.12* price

NJ_sales_Tax = 0.07*price

print('The price of item is {}'.format(price))

print('The Cost of Shipping is {}'.format(shipping_price) )

print('New Jessey Sales Tax is {}'.format(NJ_sales_Tax))

total_bill = shipping_price+NJ_sales_Tax+price

print('Total Bill {} ' .format(total_bill))

Explanation:

  • Prompt User for input of the amount of purchase
  • Calculate the shipping cost (12% of purchase price)
  • Calculate the tax (7% of the purchase price)
  • Use python's .format method to output an itemized bill

3 0
3 years ago
Other questions:
  • While the term ________ refers to an elaborate solo song frequently used in opera, the term ________ refers to sung dialogue fre
    12·1 answer
  • What type of topography should Carlos choose?
    5·1 answer
  • Explain the purpose of the frame check sequence (fcs) field in a data link frame trailer.
    7·1 answer
  • A dictionary password attack is a type of attack in which one person, program, or computer disguises itself as another person, p
    5·1 answer
  • Try of false using a combination of alt and a key underlined in the command you want is a short cut?
    6·1 answer
  • This diagram shows a number of computing devices connected to the Internet with each line representing a direct connection.
    11·1 answer
  • Steven, Marcos, and Juan are having a free-throw shooting contest. Each boy
    9·1 answer
  • Which best describes obliteration in a forged document?
    11·1 answer
  • PHP can be run on Microsoft Windows IIS(Internet Information Server):
    5·1 answer
  • Information in _____ code can be transmitted without errors over the communication network.
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!