Quiz 05

287661af-47ec-4357-a5d4-ec94bbb71365

Hi class, this quiz was an easy one. it has to parts, so let us start with it.

  1. the first part  we need to create a function called palindrome, this function will switch any character string and if it is the same we will call it palindrome

    We have tu include #include <string> in order to work with strings, and the main part is a for
    for( i= cadena.size()-1; i>=0; i–)
    {
    cadena_inv += cadena.at(i);

    }
    here is it, the for is going to order the character switched and downstairs we will evaluate with an if to know if it was a palindrome or not
    HERE IS THE CODE images (1)

  2. The second part is easier. The user will enter a range of numbers and we just have tu add the ones wich are divisible by three.
    Also is a for, but now we have an array, is like this
    for(int i=0; i<cant; i=i+1)
    {
    if(numbers[i]%3==0){
    n=n+numbers[i]; }
    }
    CODE

CC BY-SA 4.0 Quiz 05 by alibarramg is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.