Write the definition of a function printAttitude, which has an int parameter and
ID: 3831704 • Letter: W
Question
Write the definition of a function printAttitude, which has an int parameter and returns nothing. The function prints a message to standard output depending on the value of its parameter. If the parameter equals 1, the function prints disagree If the parameter equals 2, the function prints no opinion If the parameter equals 3, the function prints agree In the case of other values, the function docs nothing Each message is printed on a line by itself. Write the definition of a function power To, which receives two parameters. The first is a double and the second is an int. The function returns a double. If the second parameter is negative, the function returns 0. Otherwise it returns the value of the first parameter raised to the power of the second. Write the definition of a function signOf, which receives an integer parameter and returns a -1 if the parameter is negative, returns 0 if the parameter is 0 and returns 1 if the parameter is positive So if the parameter's value is 7 or 803 or 141 the function returns 1. But if the parameter's value is -22 or -57, the function returns -1. And if the parameter's value is 0, the function returns 0. Write a statement that declares a prototype for a function printLarger, which has two int parameters and returns no value. Write a statement that declares a prototype for a function add, which has two int parameters and returns an int. Write a statement that declares a prototype for a function powerTo, which has two parameters The first is a double and the second is an int The function returns a double.Explanation / Answer
Q1 void printAttitude(int value){
if(value==1)
cout<<"Disagree"<<endl;
else if(value==2)
cout<<"No Option"<<endl;
else if(value==3)
cout<<"Agree"<<endl;
else
{
}
}
Q2 double powerTo(double value, int second){
if(second<1)
return 0;
else
return pow(value, second);
}
Q3 int signOf(int value){
if(value<0)
return -1;
else if(value==0)
return 0;
else
return 1;
}
Q4 void printLarger(int a , int b);
Q5 int add(int a , int b);
Q6 double powerTo(double a , int b);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.