Go Bananas – WSQ11

--Originally published at Programming in C++

For this program we were supose tu search for the word “banana” in a file, even if the word is written in upper or lower cases.

This was a very similar to the WSQ10. First we need to make a file, in this case, and for obviusly reasosn, I call it “banana.txt”. We have to open the file, then, to ingonre when the word is written u¡in upper or lower, we can change the hole file to lower cases.




Pick a number

--Originally published at Programming in C++

The Program:



For this program we use 2 more libraries besides iostream. First we use srand. This is going to give us a random number.

The problem is that it will give us the same random number every time we run it.

To change that we are going to add the library time, this is going to set the random number to the current time, so it won’t give the same number unless you run it at the same second.

We are also going to need a several loops. First we want the program to run every time we insert an incorrect number, for this we use a “while”. Then we use “if” to condition when the given number is too high or too low, and for when the number is actually correct.

I consult K Hong blog. Which explains in a better way the random part. I also found this image about it: