I am using the book "C++ programming 101."
The question is:
Write a number guessing game. At the beginging of the program, assign a value to a variable called number. Give a prompt that asks for five guesses. Recieve the user's five guesses with a single cin so that you can practice with cin. Determine whether any of the guesses matches the number, and print an appropriate message if one does.
SO this is what I did: The problem is after the user types 5 numbers, nothing happens...
Thank you for all your help![]()
Code:#include <iostream.h> main() { int my_num = 3; int num[5]; cout << "I chose a number\n"; cout << "I want you to try to guess it\n"; cout << "you have five chances\n"; cout << "please type 5 numbers, no spaces please. Press Enter when you are done\n"; cin >> num[0]>> num[1] >> num[2] >> num[3] >> num[4]; if ((num[0]== my_num) | (num[1]== my_num) |(num[2]== my_num) |(num[3]== my_num) |(num[4]== my_num)) { cout << "You guessed right!" << "The number is " << my_num << "\n"; } else {cout << "You didn't guess right!";} return 0;}



LinkBack URL
About LinkBacks



