This one was a little bit difficult, but by reading the book I understand it.

q1.cpp

#include <iostream>
using namespace std;
long fibonacci(long x){
long y=0;
long z=1;
long t=0;
while (x>1){
t=y+z;
y=z;
z=t;
x=x-1;}
return t;
}
int main (){
long x;
cout << “Escribe el numero que deceas calcular= “;
cin >> x;
if (x==1){
int w=1;
cout << w;
}
else {
cout << fibonacci(x);}
return 0;}

q2.cpp

#include <iostream>
#include <string>
#include <math.h>
using namespace std;
void isPalindrome(string palindrome, int x){
string prueba;
while (x>0){
char letter = palindrome [x-1];
prueba = prueba + letter;
cout << letter;
x=x-1;}
if (palindrome == prueba){
cout << ” = Es palindrome”;
}
else {
cout << ” = no es palindrome”;
}
}
int main(){
cout << “Introduce una palabra” << endl;
string palindrome;
cin >>palindrome;
int x=palindrome.length();
isPalindrome(palindrome, x);
return 0;
}

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