Write a function titled say_hello() that outputs to the screen "Hello"
★ Modify the function so that it takes an integer argument and says hello a number of times equal to the value passed to it.
★★ Make another function that takes two integers arguments and then returns an integer that is the product of the two integers.
(i.e., integer1: 4, Integer2: 5 returns: 20)
★★★ Make a function called half() that takes an integer argument. The function must print the number it received to the screen, then the program should divide that number by two to make a new number. If the new number is greater than zero the function then calls the function half() passing it the new number as its argument. If the number is zero or less than the function exits
Call the function half() with an argument of 100, the screen output should be
I'm doing the third part to this excercise. I keep getting a failed response when I debug it. Could someone just take a gander at my function Half()? I'd greatly appreciate anyone's imput! thanks
if(n!=0) The excercise wants to call the function half() if "n" is greater than 0 so I think it should be if(n > 0)?
Can I have the
std::cout<<"Number to keep cutting in half? ";
within the function? The excercise says "the function must print the number it receives". Does that mean the user imputs a number and it reprints it?
One last question, when I call half() within the 'if' statement, shouldn't it ask me what number I want to imput again? Because it should start at the beginning of the function... I guess if you put the question inside the function like I did it would... but when I run the program it just repeats the number I imput