Posts

CPPForSchool.com: String Set 1 Assignment 6

Image
6. Write a program to check a string is palindrome or not. According to Merriam Webster's Online Dictionary : Palindrome: a word, verse, or sentence, or a number that reads the same backward or forward. For example: 1881, madam, "Able was I ere I saw Elba" This assignment was quite the eye opener.  My original approach was to place the string in backwards order within a separate string and then compare values.  Unfortunately, it did not work.  Concept wise, it seemed like a solid approach.  However, when practiced, it appears that there are some additional hurdles to overcome.  Nevertheless, the first set of screenshots demonstrates my first source code and output, which shows the downfall of the approach.  For some reason, when the second string array acquired the same characters, there seems to be some additional artifacts that comes along with it.  This results in a false interpretation of the contents of the string array. ...

CPPForSchool.com: String Set 1 Assignment 5

Image
5. Write a program to compare two strings they are exact equal or not. Strings are quite interesting to me because they are essentially just arrays with characters instead of numbers.  Nevertheless, I utilized the code from prior exercises along with creating an if/else condition to determine whether if the values in both character strings are the same.  Below is my source code and output.  For comparison, I have also included the sample source and output.

CPPForSchool.com: String Set 1 Assignment 4

Image
4. Write a program to concatenate one string contents to another. This assignment was quite puzzling at first.  However, after reviewing the string tutorials, I was able to get things moving in the correct direction.  Below is my source code and output.  I've also included the sample source code and output.

CPPForSchool.com: String Set 1 Assignment 3

Image
3. Write a program to count number of words in string. Like the past two assignments, this heavily depends on the prior tasks.  Nevertheless, the approach to finding each word is to locate the spaces between them.  This program worked as expected.  It is very exciting to see programs work after tirelessly learning as much about C++.

CPPForSchool.com: String Set 1 Assignment 2

Image
2. Write a program to display string from backward. This assignment was built upon the prior task of counting characters in a string.  From there, I had to utilize the algorithm provided within the tutorials.  Nevertheless, I am extremely happy with the outcome.  It works!  Ultimately, the program firsts determines the length of the string array, followed by printing the array counting from right to left.  This was accomplished by subtracting one from the length with each pass.

CPPForSchool.com: String Set 1 Assignment 1

Image
1. Write a program to find the length of string. This assignment was a lot of fun.  I was able to code it rather quickly.  It was quite interesting to utilize "cin.getline".  It will take getting use to using cin without an immediate set of "<<", but I am sure it comes with the territory.  Below is my source, output, and the sample source/output.

CPPForSchool.com: Array - Single Dimension Set 1 Assignment 9

Image
9. Suppose X. Y, Z are arrays of integers of size M, N, and M + N respectively. The numbers in array X and Y appear in descending order. Write a user-defined function in C++ to produce third array Z by merging arrays X and Y in descending order. For this assignment, I had a lot of trouble setting the algorithms up correctly.  It seemed like every step forward resulted in additional problems.  I eventually had to throw in the towel because I was at a complete loss.  Nevertheless, after reviewing the sample source, I began to truly understand my shortcomings and how to handle this sort of task in the future.  ------------------------------------------------------------------------------------------------------------------------- Sample Source Code ------------------------- #include <iostream> using namespace std ; void Merge ( int A [], int B [], int C [], int N , int M , int & K ); int main () { in...