Hello, this quiz consisted on fulfilling two assignments: calculate the value of e with a given accuracy and open a file and search for the word banana and count them even if they are written in capital letters. The first question was a little tricky since I didn’t actually understand if it should calculate until the given accuracy and then output the value with certain decimals or just do the calculation, so I just set the precision to the number of repetitions required to get to the number. Here’s the code for that problem:

https://github.com/CarlosGallegosT/Codes007/blob/master/Q1.cpp

The last one was a bit more complicated, I had to do some research to understand how to open a file and then turn all of the information into something easier to interact with. Then I found this page: http://stackoverflow.com/questions/7868936/read-file-line-byline. Afterwards, I turned all of the string into lower case letters so when I searche for bananas it would also consider the ones with capital letters. I didn´t understood why it did not work when I hit the Enter button within the file, I guess I will ask about it in class. Anyway, here’s the code:

https://github.com/CarlosGallegosT/Codes007/blob/master/Q2.cpp

Thanks!

 

CC BY 4.0 Bananas, bananas and e #Quiz11 by Carlos Gallegos is licensed under a Creative Commons Attribution 4.0 International License.