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 Number Guessing Game
- {
- class program
- {
- static void Main(string[] args)
- {
- Random grn = new Random(); //grn = generated random number
- int fn = grn.Next(-100, 100); //fn = final number
- bool endgame = false;
- do
- {
- Console.WriteLine("Guess the randomly generated number between -100 and +100");
- string ga = Console.ReadLine(); //ga = given answer
- int pa = int.Parse(ga); //pa = processed answer
- if (pa > fn)
- {
- Console.WriteLine("Lower!!!");
- }
- else if (pa < fn)
- {
- Console.WriteLine("Higher!!!");
- }
- else if (pa == fn)
- {
- Console.WriteLine("YOU GUESSED CORRECTLY!!! YOU WON!!! :)");
- endgame = true;
- }
- Console.WriteLine();
- } while endgame == false;
- Console.WriteLine("Thanks for playing, bye!!! :D");
- Console.WriteLine("Press any key to end the game now...");
- Console.ReadKey(true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement