QUIZ 5

42c150433839bad235f1f83925cf3875527c7bb3-vector-storefront_189303863

Hello people.

I am here to post about the quiz that I made some days ago about two programs: One which has to:

  1. Create a function called is_palindrome which receives a string as a parameter and returns true if that string is a palindrome, false otherwise. Remember that a palindrome is a word that is the same forward or backward. For full points your function must ignore case and must work with any character (not just letters). So (“Dad$dad” is a palindrome even though the D is capital and d is lower case).

On this program I learned how to use vectors and make a palindrom with it, taking the word and then taking the reverse of the word, Yeah, vectors rules.

To learn more about vectors on C:  http://www.cplusplus.com/reference/vector/vector/

Here my code:

q5

Running:

palg

And the second one:

  1. Create a function called find_threes that receives as a parameter a list (or Vector or array for C++ students) of numbers and returns the sum of all numbers in that list that are evenly divisible by 3. Note if using vectors, you will need an additional parameter to represent the number of numbers in the array. So if the list was [0,4,2,6,9,8,3,12], the function would return 30 (0+6+9+3+12)

Here, we have to use an array to get the range of numbers that we are going to use in our function “threes”. It was a little bit difficult but with the help of other students of the class I can make it.

The code:

3

And running:

g3

To more information check all my codes on github and dont forget to make questions or add comments to stay in contact with me;D

https://github.com/eduardomrlsg/TC101/blob/master/Quiz5Palindrome

https://github.com/eduardomrlsg/TC101/blob/master/Quiz5Threes

Regards, EdMo.

CC BY-SA 4.0 QUIZ 5 by eduardomoralesg is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.