diff options
| author | Benjamin Schroeder <[email protected]> | 2021-11-10 18:56:41 -0800 |
|---|---|---|
| committer | Benjamin Schroeder <[email protected]> | 2021-11-10 18:56:41 -0800 |
| commit | 2fb4b2a2c1d5b40bba3697f0a651bb17df9021e7 (patch) | |
| tree | ab5ecda4c3e3785e9394e8465382345c80cc7670 /CST116F2021-Lab6/Lab6ExerciseFunctions.cpp | |
| parent | Lab6 Exercises (diff) | |
| download | cst116-lab6-bensprogramma-2fb4b2a2c1d5b40bba3697f0a651bb17df9021e7.tar.xz cst116-lab6-bensprogramma-2fb4b2a2c1d5b40bba3697f0a651bb17df9021e7.zip | |
Update on exercises
10.10,
10.14,
10.15
Diffstat (limited to 'CST116F2021-Lab6/Lab6ExerciseFunctions.cpp')
| -rw-r--r-- | CST116F2021-Lab6/Lab6ExerciseFunctions.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/CST116F2021-Lab6/Lab6ExerciseFunctions.cpp b/CST116F2021-Lab6/Lab6ExerciseFunctions.cpp index dd96a34..4f9d8fc 100644 --- a/CST116F2021-Lab6/Lab6ExerciseFunctions.cpp +++ b/CST116F2021-Lab6/Lab6ExerciseFunctions.cpp @@ -82,4 +82,80 @@ void printData(int intData[ARRAY_SIZE][2], string stringData[ARRAY_SIZE][2]) } +//11c +//10.15 Programming Exercises +//pp 292 - 293 +//10 pts #1 +// +void isPalindrome(char User_Input[35]) +{ + char Rev[35]{}; + strcpy(Rev, User_Input); + _strrev(Rev); + int Pal = strcmp(User_Input, Rev); + + if (Pal == 0) + { + cout << "\n'" << User_Input << "' is a Palindrome! \n"; + } + else if (Pal == 1) + { + cout << "\n'" << User_Input << "' is not a Palindrome."; + } +} + + + +void isAlphaStr(char User_Input[35]) +{ + int i = 0; + int k = 0; + while (User_Input[i]) + { + if (isalpha(User_Input[i])) + k++; + else k = 0; + i++; + } + + //int k = 0; + //for (int i = 0; User_Input[i] == '\0'; i++) + //{ + // if (isalpha(User_Input[i])) + // { + // k++; + // } + + //} + if (k == 0) + { + cout << "\n'" << User_Input << "' does not contain just alphbetic characters\n"; + } + + else if (k != 0) + { + cout << "\n'" << User_Input << "' contains only alphabetic characters\n"; + } + +} + + +void countChar(char User_Input[35], char part_char) +{ + int count = 0; + for (int i = 0; i < 35; i++) + { + if (User_Input[i] == part_char) + { + count++; + } + } + + cout << "\ncharacter: " << part_char << " ... " << count << " counted.\n\n"; +} + + + + + |