/* --- Lab Number: 11 Created For: CS 141 Instructor: Dale Reed Semester: Spring 2018 Date: April 03, 2018 --- The objective of this lab is to learn about recursive in C++. In today's lab, you will be provided 2 functions in which work in an iterative fashion. Your goal is to take those same functions and re-write them recursively. You do not need to alter or modify the iterative functions. Grading Rubric: 1. (1 point) Problem 1: Print out all odd positive number that are less than the user input. For example, if the user input is 5, your program should print out 1 3. Note: For our sake, let's assume that user input can only be positive numbers. Our main goal is to learn recursion! 2. (1 point) Problem 2: Count the number of upper-case letters in a word. For example, if user input is ''heLLo'', your program answer that there are 2 upper-case letters Note: Assume the word can be of size length 10, including null character. 3. (1 point extra credit) Extra-credit Problem: Display a string backward (recrusively). For example, if user input is "heLLo", your program should display "oLLeh" Note: You will need to modify main to add the function calls. It is your job to determine what the parameters will be for your recrusive functions. (You will most likely need to add more parameters than what you see in the iterative versions). */ #include <iostream> using namespace std; // The following function prints all odd positive numbers (starting at 1) in an iterative fashion. void iter_printOddPositive(int value){ // Simple loop to go up to the number specified by the user for(int i = 1; i < value; i++){ // Standard way to check if a number is odd. if(i % 2 != 0){ cout << i << " "; } } } // The following function counts all upper case letters in a given word in an iterative fashion. int iter_countUpperCase(string word){ int count = 0; int length = word.length(); // Iterate through each letter in the word for(int i = 0; i < length; i++){ // Use the library to check if it is upper-cased. If it is, then add to the count. if(isupper(word[i])){ count++; } } // Return the count of total number of upper cased letters in a word. return count; } int main(){ //Problem 1: Print odd numbers up to user input val int userInput1; cout << "Please enter a number: "; cin >> userInput1; cout << endl; // Problem 1: Iterative cout << "Iterative Result for all positive numbers less than user input: " << endl; iter_printOddPositive(userInput1); // Problem 1: Recursive cout << "Recursive Result for all positive numbers less than user input: " << endl; //TODO: Add your function call here for the recursive version of the above problem: //--- //--- //Problem 2: Count number of capitalized letters in a word. string userInput2; cout << "Please enter a word: "; cin >> userInput2; cout << endl; // Problem 2: Iterative cout << "Iterative Result for all positive numbers less than user input: " << endl; cout << "The count: " << iter_countUpperCase(userInput2) << endl; // Problem 2: Recrusive cout << "Recursive Result for counter uppercase for a word: " << endl; //TODO: Add your function call here for the recrusive version of the above problem. // Problem Extra Credit: Recursive //TODO: Add your function call for the Extra Credit- Using recursive, print the word backwards. (userInput2 can be used here). return 0; }