Quiz 5

 

Finally, I switched from CodeBlocks to Cygwin and Notepad++.

For this quiz, we were required to make two programs. One had to verify if a word was a palindrome or not, and the other had to make the summatory  of all the numbers evenly divisible by three, from a list of numbers provided by the user.

The second problem was way easier for me than the first one, since I had never used strings in my life. After doing some research on strings, I tried my first version, which did not work. Today, Salvador Ibarra´s blog was updated with a really helpful video on the subject, in Spanish. Also, his code on github helped me a lot. So basically, thank you Salvador, I owe you one.

But the thing is not only to copy, but to understand, so here I´ll explain you my version of the palindrome program.

First of all, a palindrome is a word or a number that can be read normally or backwards and yoy get the same word. For example Anna, read it backward and it is the same word. 111 is a palindrome number.

In order to make a program to capable of deciding if a word is a palindrome or not, I had to use strings in C++. I made four strings and a string function.  Two were really important, string palabra and string backwards. On string palabra the program stores the word provided by the user, and on string backwards it stores it backwards.

The process made to store the word backwards was done with a for loop. The parameter to continue the for loop was the length of the string palabra, which I stored on an integer variable called largo. To get that value, you just write the name of the

for loop

Continue reading “Quiz 5”