Skip to content

Instantly share code, notes, and snippets.

@karan-ta
Last active September 19, 2020 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karan-ta/adc693d8d78d3a7bdbcf97d787d9a6ba to your computer and use it in GitHub Desktop.
Save karan-ta/adc693d8d78d3a7bdbcf97d787d9a6ba to your computer and use it in GitHub Desktop.
import 'dart:io';
import 'dart:math';
main ()
{
Random r = Random ();
int computer = r.nextInt(11);
print ("please start guessing number");
while (true)
{
String playerstring = stdin.readLineSync ();
int player = int.parse (playerstring);
if (computer > player)
{
print ("my number is higher");
}
if (computer < player)
{
print ("my number is lower");
}
if (computer == player)
{
print ("you got it!");
break;
}
}//while loop ends
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment