Write a function called timesTen that returns back to the caller the value passe
ID: 3536438 • Letter: W
Question
- Write a function called timesTen that returns back to the caller the value passed into the function multiplied by 10. If the value passed into the function is negative, the function also returns the string "negative". (If information you need to complete this function is missing, complete it on your own making reasonable assumption(s). State your assumptions.) (10 points)
Explanation / Answer
#include<iostream>
using namespace std;
char* timesTen(int* k)
{
*k=*k*10;
char* str = new char[10];
if(k<0)
{
str="NEGATIVE";
}
else str="";
return str;
}
int main()
{
char* k;
int p=-5;
k=timesTen(&p);
cout<<k;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.