Respuesta :
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.