A.I, Data and Software Engineering

Random number in different programming languages


Random numbers are important in almost any programming paradigm. For example, in neural network, sometimes we need to initialise random weights. In game development, random generators are considered as God.

Here, we will quickly go through creating a random number in some common programming languages.

Random in C/C++

Random in C#

Random in Kotlin

Random in Java

Similar to C#, to generate a random number, use Random class from util library.

Random in Python

Random in Swift

Swift 4.2+ makes it easier to generate a random number.

Random in Dart

Random in JavaScript/React.JS

Add comment

A.I, Data and Software Engineering

PetaMinds focuses on developing the coolest topics in data science, A.I, and programming, and make them so digestible for everyone to learn and create amazing applications in a short time.

Pin It on Pinterest


You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

Petaminds will use the information you provide on this form to be in touch with you and to provide updates.