When I first look at the Quiz, I didn´t know what to do, but with some research and using the string library I realize how to write the code and eventually, compile and run it.

The first programm is the one that calculates the fibonacci of a given position number, it was way difficult than I thought, but it the end…it works just fine.

 <iostream> //Ever Ibarra Almaral TC1017
using namespace std;

long fibonacci(long n){
  long x;
      if (n<=1){
      x=n;
      return x;
  }
      else{
      if(n>1){
          int y=0;
          int z=1;
          long temp;
          for(int i=1;i<n;i++){
      temp=y+z;
      y=z;
      z=temp;
    }
    return z;}
  }
  }

  void newline(){
    cout<<endl;
  }
  int main () {
    long a;
  cout << "Hello, I´m a calculator of fibonacci algorithm";
  newline();   newline();
  cout << "Please, enter the position of the number in the fibonacci algorithm: ";
  cin >> a;
  newline();
  cout << "The fibonacci number is: " << fibonacci (a);

  return 0;


}

https://github.com/everibarra/TC101-C-/blob/master/PROGRAMM%201%20QUIZ07

The second programm deals with strings in order to check if the word is a palindrome or not.

 <iostream> //Ever Ibarra Almaral TC1017
<string>
using namespace std;

string palindrome(string a){

a=string(a.rbegin(), a.rend());
return a;
}

void newline(){
  cout<<endl;
}

int main(){
  string b;
  cout<<"Enter the string "<<endl;
  cin>>b;
  newline();
  cout<<"the reverse string equals to "<<palindrome(b);
newline();
  if (b==palindrome(b)){
    cout<<"The string is a palindrome"<<endl;
    newline();
  }
  else{
    cout<<"The string its not a palindrome"<<endl;
    newline();
  }

  return 0;
}

https://github.com/everibarra/TC101-C-/blob/master/PROGRAMM%202%20QUIZ07

 

CC BY 4.0 #QUIZ07 by Ever Ibarra Almaral is licensed under a Creative Commons Attribution 4.0 International License.