Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Random number generator
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//Microsoft (R) Visual C# Compiler version 3.4.0-beta4-19562-05 (ff930dec) //Copyright (C) Microsoft Corporation. All rights reserved. using System; using System.Collections.Generic; using System.Linq; namespace Rextester { public class Program { public static void Main(string[] args) { bool tryagain=true; int big; int small; Random r=new Random(); Console.WriteLine("Hello,this is a random number generator made by Matthew"); Console.WriteLine("\nWhat is the smallest number?\n"); int number1=Convert.ToInt32(Console.ReadLine()); Console.WriteLine("\nOk,what is the biggest number?\n"); int number2=Convert.ToInt32(Console.ReadLine()); if(number1>number2){big=number1; small=number2;} else{small=number1; big=number2; } Console.WriteLine(""); while(tryagain){ for(int a=0;a<3;a++){ Console.Write("."); System.Threading.Thread.Sleep(500);} Console.WriteLine("\n\nYour random number is "+r.Next(small,big+1)); Console.WriteLine("\nDo you want to generate it again?\n"); string b=Console.ReadLine(); if(b.ToLower()!="yes"){Console.WriteLine("\nThank you for trying my random number generator!"); tryagain=false; }else{Console.Write("\n");} }} }
Show compiler warnings
[
+
]
Show input
edit mode
|
history
|
discussion