Write a C function named absValue to return the absolute value of any integer pr
ID: 3869471 • Letter: W
Question
Write a C function named absValue to return the absolute value of any integer provided as an input parameter, Recall that the absolute value of any positive integer a or 0 is just the integer itself: for any negative integer the absolute value is -1 * a. Circle the letter of an appropriate prototype statement for this function from the following possible choices: a. int absValue (a, -1) b. void absValue (int a): c. int absValue (int a): d. void absValue (int): a) We would like to call absValue function from the main function in our program. Write the C statements that could be added to the main function to declare any needed variable(s) and assign your choice of example values. b) Write the statement that could be added to the main function to call the absValue function. Display the result.Explanation / Answer
Answer - 01
program.c --
#include<stdio.h>
int absValue(int);
int main()
{
printf(" -5 : %d ", absValue(-5));
printf(" 0 : %d ", absValue(0));
printf(" 5 : %d ", absValue(5));
return 0;
}
int absValue(int num)
{
if(num < 0)
return num;
else
return ((-1) * num);
}
Answer - 02
int absValue(int a);