Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1 . A series of whole numbers in which each number is the sum of the two precedi

ID: 3548604 • Letter: 1

Question

1. A series of whole numbers in which each number is the sum of the two preceding numbers.

Beginning with 0 and 1, called Fibonacci series. The sequence of Fibonacci numbers would

be 0,1,1, 2, 3, 5, 8, 13, 21, 34, etc. Using the formula n = n(?1) + n(?2), where the n(?1)

means "the last number before n in the series" and n(?2) refers to "the second last one

before n in the series." You can calculate Fibonacci series.

Write a program that inputs a integer n and prints n number in Fibonacci series. Here is the

sample run.

Your program: please insert n

User: 5

Your program: 3

Hint: you can use recursive function to solve the problem.

2. A palindrome is a string that is spelled the same way forward and backward. Some examples

of palindromes are:

Explanation / Answer

#include<iostream.h>

#include<conio.h>


rec_fibo(int);


void main()

{

clrscr();



int n,i;


cout<<"Enter the total elements in the series : ";

cin>>n;

cout<<" The Fibonacci series is: ";

for(i=0;i<n;i++)

{

cout<<rec_fibo(i)<<" ";

}


getch();

}


rec_fibo(int n)

{

if(n==0)

return 0;

else if(n==1)

return 1;

else

return rec_fibo(n-1)+rec_fibo(n-2);

}


/////////////////////////////////////////

bool IsPalindrome(const string& str)

{

if (str.empty())

return false;


int i = 0; // first characters

int j = str.length() - 1; // last character


while (i < j)

{

if (str[i] != str[j])

{

return false;

}

i++;

j--;

}

return true;

}


//////////////////////////////

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr();

int i,j,n,a[10][10],b[10][10],c[10][10];

cout<<"enter the order of matrix A";

cin>>n;

cout<<"enter value of elements of matrix A"<<" ";

for(i=0;i<n;i++)

{

for(j=0;j<n;j++)

{

cin>>a[i][j];

}

}

cout<<"enter the order of matrix B";

cin>>n;

cout<<"enter values of elements of matrix B"<<" ";

for(i=0;i<n;i++)

{

for(j=0;j<n;j++)

{

cin>>b[i][j];

}

}

cout<<"values of elements of matrix A are"<<" ";

for(i=0;i<n;i++)

{

for(j=0;j<n;j++)

{

cout<<" ";

cout<<a[i][j];

}

cout<<" ";

}

cout<<"values of elements of matrix B are"<<" ";

for(i=0;i<n;i++)

{

for(j=0;j<n;j++)

{

cout<<" ";

cout<<b[i][j];

}

cout<<" ";

}

cout<<"subtraction of matrix A and B is"<<" ";

for(i=0;i<n;i++)

{

cout<<" ";

for(j=0;j<n;j++)

{

c[i][j]=a[i][j]-b[i][j];

cout<<c[i][j]<<" ";

}

cout<<" ";

}

getch();

}


//////////////////////////

#include <iostream>

#include <cstdlib>

#include <fstream>

using namespace std;



int main()

{

int count=0;

char password, verify1, verify2, verify3, verify4;



cout << "Welcome. " <<

"This program helps youu to determine the strength " <<

"of any password you may chose, based on all of the following criteria for password strength: " <<

"1.At least 12 total characters. " <<

"2.At least one digit. " <<

"3.At least one lowercase letter. " <<

"4.At least one uppercase letter. " <<

"5.At least one character that is neither a letter nor a number, " <<

"(for example, a punctuation character). ";


cout << "Now enter your choice of password: ";


do

{

cin.get(password);


if (isupper(password))

verify1 = 'y';

else

verify1 = 'n';


if (islower(password))

verify2 = 'y';

else

verify2 = 'n';


if (isdigit(password))

verify3 = 'y';

else

verify3 = 'n';


if (isalpha(password))

verify4 = 'y';

else

verify4 = 'n';


count ++;

}while (password != ' ');


if ((verify1 == 'y' && verify2 == 'y') && (verify3 == 'y' && verify4 == 'n') && (count >= 12))

{

{

cout << "This password looks pretty good. ";

}

}

else

{

if (verify1 == 'n')

cout << "Your password does not have at least one uppercase letter. " << endl;


if (verify2 == 'n')

cout << "Your password does not have at least one lowercase letter. " << endl;


if (verify3 == 'n')

cout << "Your password does not have at least one digit. "<< endl;


if (verify4 == 'y')

cout << "Your password does not have at least character that is neither "

"a letter nor a number. " << endl;

if (count < 12)

cout << "Your password should be at least 12 characters long. "<< endl;

}



while ((verify1 == 'n' || verify2 == 'n') || (verify3 == 'n' || verify4 == 'y') || (count < 12))

{

cout << "Please enter another password for verification. ";

do

{

cin.get(password);

}while (password != ' ');

}


char wait; cin >> wait;

return 0;


}