My code is: #include <iostream> #include <ctime> #include <cstdlib> using namespace std; int main (){ int numero; srand (time (NULL)); int x= rand () % 101; cout<<“I’ll give you a number beteen 0 and 100, guess the number”<<endl; cin>>numero; while… Continue Reading →
WSQ06
In this activity, the program had to choose a random number from 0 to 100, then, the user had to guess what number it is. For this, the program had to state that the number that was input in the program was too high or too low.
I had a lot of problems with this one because I couldn’t create the random number. Later, I discovered that I had to use “srand”, then, I had another problem. I had a wrong order with the loops, I could perfectly go from “Too high” to “Too low”, but when it had to go back again to “Too high” the program ended, so I had to change the order of the loops. I used two “ifs” inside a “while”, so it would never end until the user guess the number.
I think this was the hardest of the activities for me because it involved more variables and terms, but finally I could do it.
Hi, so this WSQ was about a program that generated a random number then we have to guess it using a loop and also a counter that counted how many times do we tried it and print the number. Here’s my code: And here it is working in the command line: I also checked David’s […]
Hi today I created a small game program on python3 called pick a number. I had issues concerning how to create a loop and to choose the best condition which was « while ». To create a random figure between 1 and 100, you have to choose « random.randrange(1, 101) ». Why 101 ? Because if it was 100… Lire la suite #WSQ06 – Pick a Number
007
Random number generator was a harder task. I tried to make it on my own, according to what my logic made me do, but I just couldn’t make it.
So first, I checked this website, which pretty much explained how to do it:
http://www.dreamincode.net/forums/topic/14057-producing-random-numbers/
And then I just fixed some little details to make it work as it was required.
Then, I tried to make the “attempts’ counter”, which I almost made it work by my own. This website helped me realize my mistakes and I was able to correct them:
http://www.cplusplus.com/forum/beginner/15560/
And that was it, I used “do…while” function and some if’s for the loops. You can check my code if you want here:
This time the assignment was to write a program that picks a random integer in the range of 1 to 100. It then asks the user to guess the number, it continues to run with hints of ’too high’ or ’too low’, until they guess right. The program also tells the user how many guesses they had made. […]
So this WSQ was kind of hard for me. I didn’t know many things that I want to share with you. First to generate a random number you have to write (How you want to call you variable) = rand()% (highest number you want) + 1; Second, it is not enough with iostream, you need to add… More Pick a random number
This program was an relatively easy task (aside from validating the user input). I had to consult some web pages and the book to understand better while loops and input validation for my program to work without errors. If you read those web pages you can easily understand the use of exceptions and while loops. […]
You can find the program here
https://github.com/dianagdv/TC101/blob/master/WSQ06
For this task I asked Samir Godinez, a friend that took programing class last semester
You can find the program here
https://github.com/dianagdv/TC101/blob/master/WSQ06
For this task I asked Samir Godinez, a friend that took programing class last semester