M

@MihaiPopa1

Program to select some candies

SQL
4 years ago
-- Create a table CREATE TABLE candy ( name TEXT NOT NULL, weight INTEGER, price INTEGER ); -- Insert some values

Code 6 - "Hello, world" 5 times

Lua
4 years ago
-- Program to print "Hello, world!" on screen, 5 times in pure Lua for x = 1,5,1 do print("Hello, world!") end print("\nDone!")

Pie chart in R

R
4 years ago
x <- c(32,24,16) # Define a vector labels <- c("Java","Scala","Kotlin") # Define the second vector pie(x, labels) # Plot the pie chart

Code 5 - Cube a number

Lua
4 years ago
-- Code 5 - Cube a number -- Lua Programming print ("Enter a number to cube.") x = io.read("*n") y = x^3 print ("Your inputed number is:",x)

Code 4 - Square a number

Lua
4 years ago
-- Code 4 - Square a number -- Lua Programming print ("Enter a number to square.") x = io.read("*n") y = x^2 print ("Your inputed number is:",x)

Code 3 - The number "x" 10 times

Lua
4 years ago
-- Program to print the number "x" on screen, 10 times in Lua for x = 1,10,1 do print(x) -- prints the number "x" on screen 10 times -- such as: -- 1 -- 2 -- 3 -- ...

Code 2 - If/Else in Lua

Lua
4 years ago
-- If/Else in Lua -- Lua Programming x = io.read("*n") y = io.read("*n") if ( x == y ) then print ("Lua!") else print ("Python!") end

Code 4 - Swapping 3 values

Bash
4 years ago
#!usr/bin/sh # Swapping values echo "Enter w:" read w echo "Enter x:" read x echo "Enter y:" read y

Code 3 - Swapping values

Bash
4 years ago
#!usr/bin/sh # Swapping values echo "Enter x:" read x echo "Enter y:" read y echo "Before swapping:" $x $y z=$x

Print Fibonacci numbers less than 250

Fortran
4 years ago
!Print Fibonacci numbers less than 250 !Fortan Programming READ(*, *)T0,T1 T0=0 T1=1 2 T=T0+T1 WRITE(*, *)T IF(T.LT.250)THEN T0=T1 T1=T

Code 10 - Random Numbers

Kotlin
4 years ago
// Code 10 - Random Numbers // Kotlin Programming fun rand(start: Int, end: Int): Int { require(start <= end) { "Illegal Argument" } return (start..end).random() } fun main() { var start = 1

Code 9 - Rock, Paper, Scissors (RPS)

Kotlin
4 years ago
// Code 9 - Rock, Paper, Scissors (RPS) // Kotlin Programming import java.util.Scanner fun rand(start: Int, end: Int): Int { require(start <= end) { "Illegal Argument" } return (start..end).random() }

Code 8 - Nested if

Kotlin
4 years ago
// Code 8 - Nested if // Kotlin Programming fun main() { var x = 7 var y = 2 if (x < 5) { if (y > 10) { println("Java") } }

Code 7 - Nested for loops

Kotlin
4 years ago
// Code 7 - Nested for loops // Kotlin Programming fun main() { for (x in 1..5) { for (y in 1..3) { println("Hello " + x + " " + y) } } }

Code 6 - Print the number "x" 10 times with a Done! indicator

Kotlin
4 years ago
// Program to print the number "x" 10 times with a Done! indicator // Pure Kotlin fun main() { for (x in 1..10) { println(x) } println("\nDone!") }

Code 5 - Print Hello, world! 5 times with Done! indicator

Kotlin
4 years ago
// Program to print Hello, world! 5 times with "Done!" indicator // Pure Kotlin fun main() { for (x in 1..5) { println("Hello, world!") } println("\nDone!") }

Code 3 - Print the number "x" 10 times

Kotlin
4 years ago
// Program to print the number "x" 10 times // Pure Kotlin fun main() { for (x in 1..10) { println(x) } }

Code 4 - If in a for loop

Kotlin
4 years ago
// Code 4 - If in a for loop // Pure Kotlin fun main() { for (x in 1..5) { if (x < 3) { println("Bad!") } else if (x == 3) { println("OK!")

Code 2 - Print Hello, world! 5 times

Kotlin
4 years ago
// Program to print Hello, world! 5 times // Pure Kotlin fun main() { for (x in 1..5) { println("Hello, world!") } }

Code 3 - The number "x" 10 times

C++
4 years ago
// Program to print the number "x" on screen, 10 times in pure C++ #include <iostream> int main() { int x; for(x = 1; x < 11; ++x ) { std::cout << x << "\n"; /* prints the number "x" on screen 10 times # such as: 1 2