Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function called timesTen that returns back to the caller the value passe

ID: 3536438 • Letter: W

Question

  1. 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)
I thought that you couldn't return two different data types through a function. I thought that you couldn't return two different data types through a function.

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;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote