Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication29
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random number = new Random();
- int nr1 = number.Next(1, 10);
- int guess = 0;
- int counter = 0;
- Console.WriteLine("Iยดm thinking of a number between 1 to 10.");
- while (guess != nr1)
- {
- Console.WriteLine("You are at the {0} try.", counter + 1);
- guess = Convert.ToInt32(Console.ReadLine());
- if (guess < nr1)
- {
- Console.WriteLine("No, the number I have in mind is higher than {0}", guess);
- }
- else if (guess > nr1)
- {
- Console.WriteLine("no, the number I have in mind is lower than {0}", guess);
- }
- counter++;
- if (counter == 5)
- {
- Console.WriteLine("You have lost the game.");
- break;
- }
- }
- Console.WriteLine("Welldone! the answer was {0}", nr1);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement