Here´s my quiz 11, it was a little more complicated than I thought, but in the end I receive some help from my friends Marco Patiño and Esaú Preciado, and well they teach me how to do the programms.

so here are my programms

q1.

 <iostream>
<iomanip>
using namespace std;

void newline(){
  cout<<endl;
}

double factor(int a){
double output= 1.0;
for (int i = 1; i <= a; i++){
  if (a == 0)
  return output;
  else
  output = output * i;
  }
return output;
}

double define_e(int exact){
double output1 = 0.0, output2 = 1.0;
for(int i= 1; i<1000 ; i++){
  output1 = output2;
  output2 = output1 + (1/factor(i));
}
cout << fixed << setprecision(exact) << output2 << endl;
return output1;
}
int x = 0;

int main(){
float e;
string z;
cout<<"Hi, I´m a calculator of the e constant "<<endl;
newline();
cout<<"Please insert how precisely you want this mathematical constant "<<endl;
newline();
cin>>e;
newline();
cout<<"The result equals to "<<define_e(e)<<endl;
newline();
}
return 0;
}

 

q2.

 <iostream>
<string>
<fstream>
using namespace std;

int main(){
string Read;
string Banana = "banana";
char archive[50];
int x = 0;
int y = 0;
int counter = 0;
cout << "Write the name of your file: ";
cin >> archive;

ifstream read_file (archive);
if (read_file.is_open()){
while (getline(read_file , Read)){
      x = 0;
      while (x < Read.length()) {
        char character = Read[x];
        if ( character == 'B' || character== 'b'){
          y = x + 1;
          char character = Read[y];

          if (character == 'A' || character== 'a'){
            y++;
            char character = Read[y];

            if (character == 'N' || character== 'n'){
              y++;
              char character = Read[y];

              if (character == 'A' || character== 'a'){
                y++;
                char character = Read[y];

                if (character == 'N' || character== 'n'){
                  y++;
                  char character = Read[y];

                  if (character == 'A' || character== 'a') {
                    counter++;
                  }
                }
              }
            }
          }
        }
        x = x + 1;
}

    }read_file.close();
    }else{
      cout << "Error 404 not found" << endl;
    }
cout << "I found " << counter << " bananas....So eat them all!!!...or not..." << endl;
return 0;
}

Also on github.

Program1.

https://github.com/everibarra/TC101-C-/blob/master/quiz11q1.cpp

Program2

https://github.com/everibarra/TC101-C-/blob/master/quiz11q2.cpp

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