#include #include #include #include using namespace std; // Exam 1 Follow Up Lab /* 5. Write a function called “absoluteValue” that computes and returns the absolute value of an input number. Do not use the built-in function abs()! Here is test code showing how it should work: cout << absoluteValue(5); // should display 5 cout << absoluteValue(-13); // should display 13 */ /* 6. Write a function that takes a string word and a whole number n as input parameters. This function should print word to the screen n times, separated by spaces (there should not be a trailing space at the end!). For testing, name the function talkTalkTalk */ /* 7. Write a function that will “swap” the values of two given integer variables. Here is an example: int x = 20; int y = 30; myswap(x, y); cout << x << ", " << y; //should print 30, 20 */ /* 8. Write a function that takes an integer n and asks the user repeatedly to guess the secret word. If the user guesses “shazzmoo”, return true. If the user guesses incorrectly n times, return false. For testing, name the function login. */ /* 9. You are given a function random, which takes no input parameters and returns a random double between 0.0 and 1.0. Write the definition for another function that takes an integer as a parameter and prints to the screen that many random numbers between 5 and 15 (inclusive). For testing, name the function printRandoms. */ // the given function double random() { return rand(); } // write your function here int main() { // necessary for generating random numbers srand(time(NULL)); // Q5 tests cout << absoluteValue(5); // should display 5 cout << absoluteValue(-13); // should display 13 // Q6 tests talkTalkTalk("banana", 17); // should print "banana" 17 times // Q7 tests int x = 20; int y = 30; myswap(x, y); cout << x << ", " << y; //should print 30, 20 // Q8 tests login(4) // should give you 4 tries to guess "shazzmoo" // Q9 tests printRandoms(14) // should print 14 random numbers between 5 and 15 system("pause"); }