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]
3 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]3 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
An important task that the operating system performs is ____, which keeps track of the files stored on a computer so that they c
finlep [7]
#1) An important task that the operating system performs is ____, which keeps track of the files stored on a computer so that they can be retrieved when needed.
Answer: File Management System. Keeps track of where files are stored and determines how the files are stored following the operating system file allocation policies. It uses available storage space efficiently for files and creates a record/log of all file usage. It allocates a file to a user if is free, and if they are permitted access to it. Then de-allocates file when the user is finished with it.
8 0
3 years ago
Allan needs to ensure that an object is in a very precise location on a slide. He decides to use the Ruler option to achieve thi
shusha [124]

Answer:

It can be found on View tab.

Explanation:

The view tab on Microsoft Power point is the 9th tab when counting from the left. When clicked, the view tab displays a number of tools that are aimed at visualizing how slides appear.

The ruler function is one of those tools. It is used to ensure that an object is placed or appears at a specific location in the slides. The ruler tool can be found in the Show Box which is the third box from left after Presentation View and Master View.

8 0
4 years ago
Read 2 more answers
Water is constantly in motion.<br> True or false
motikmotik

Answer: true

Explanation: yes water is constantly in motion

7 0
3 years ago
Which of the following statements is/are true by definition.
Rudik [331]

Answer:2. electrical equipment shall be considered readily accessible to those to whom ready access is requisite when it is capable of being reached quickly for operation by using a portable ladder.

Explanation:

3 0
3 years ago
3. Find the best.
Tamiku [17]

Answer:

1. is the answer

Explanation:

<h2>mark me as brainlest</h2>

6 0
2 years ago
Other questions:
  • .<br> 1. Press the _______ key to move to the next cell in a row.
    14·2 answers
  • Write a generic C++ function that takes an array of genericelements and a scalar of the same type as the array elements. Thetype
    13·1 answer
  • For some reason, Danica's classmate George could not find the registered symbol in the symbol gallery. He is selling
    14·1 answer
  • Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 te
    13·1 answer
  • At each layer of the OSI model, data is appended to the original message and then sent on to the next lower layer. What is this
    10·1 answer
  • A or an is a simple chip with two or more processor core
    5·1 answer
  • A list is a collection that ______________
    9·1 answer
  • The advancements in which of the following technologies has most changed the American job market in recent years?
    14·2 answers
  • The lower band and upper band of integer data type​
    6·1 answer
  • Please answer me <br> in Assignment - Algorithms
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!