Here are the answers of my quiz #07.
Question 1
#include <iostream>
using namespace std;

long fibonacci(long x){
long y=0, z=1, w=0;
while (x>1)
{
w=y+z;
y=z;
z=w;
x=x-1;
}
return w;
}

int main()
{
long x;
cout << “Introduce un número”<< endl;
cin >> x;
if (x==1)
{
int w=1;
cout << “De acuerdo a la sucesión fibonacci el número es “<< w << endl;
}
else
{
cout << “De acuerdo a la sucesión fibonacci el número es “<<fibonacci(x) << endl;
}
return 0;
}

Screenshot from 2015-10-18 23:28:30

Question 2
#include <iostream>
#include <string>
using namespace std;

bool IsPalindrome(string x)
{
int w= x.length();
string palabra=””;
int y=w-1;
do {
palabra=palabra+x[y];
y=y-1;
} while (y>=0);

if (x == palabra){
return true;}
else {
return false;}
}
int main ()
{
string x;
cout << “Escribe una palabra ” << endl;
cin >> x;
IsPalindrome(x);
if (IsPalindrome(x) == true){
cout<<“Es un palíndromo”<<endl;
}else{
cout<<“No es un palíndromo”<<endl;
}
return 0;}

Screenshot from 2015-10-18 23:44:13

CC BY 4.0 Quiz #07 by chrisorozco97 is licensed under a Creative Commons Attribution 4.0 International License.