Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Perl code to print your name

# this  is ranjith
print "Hello friends, this is Ranjith!\n";

Execute Node.js Online

const r1 = require('readline');

const r = r1.createInterface({
  input: process.stdin,
  output: process.stdout
});
/*
r.question('What do you think of Node.js? ', (answer) => {
  // TODO: Log the answer in a database
  console.log(`Thank you for your valuable feedback: ${answer}`);*/
r.question("Enter a number\n");
  r.close();

/*r.question("Enter a number\n");
r.question("Ente another number\n");*/
//var op = r1.question("Choose an operation (+,-,/,*)\n");
//var result;

Java example to print Hi and Hello world in separate lines

public class HelloWorld{

     public static void main(String []args){
        System.out.println("Hi!");
        System.out.println("Hello, World!");
     }
     
}

PHP database example to connect, get data from MySQL

<?php
$driver = 'mysql';
$database = "dbname=CODINGGROUND";
$dsn = "$driver:host=localhost;$database";

$username = 'root';
$password = 'root';

try {
   $conn = new PDO($dsn, $username, $password);
   echo "Database CODINGGROUND Connected";
}catch(PDOException $e){
   echo $e->getMessage();
}
$sql = 'SELECT  * FROM users';
$stmt = $conn->prepare($sql);
$stmt->execute();

while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
  foreach($row as $value)
  {
    echo sprintf("%s", $value);
  }
  echo "\n";
}
?>

SCALA example to print Hello World

object HelloWorld {
   def main(args: Array[String]) {
      println("Hello, world")
   }
}

Java example to print text in separate lines

public class HelloWorld{

     public static void main(String []args){
        System.out.println("NAMA : ADNAN ABIDIM");
        System.out.println("NIM : 17220010");
        System.out.println("TUGAS 2 ");
     }
}

Java example to print Nama and NIM

public class HelloWorld {

     public static void main(String []args){
        System.out.println("Nama : Jean Baptista Jimmy");
        System.out.println("NIM : 17220034");
     }
}

Python example to input name, age and multiple, divide the age by given factor

userName=input('Please enter your name:')     
age=int(input('Please enter your age:'))

factor=2
finalAge=age+factor
multAge=age*factor
divAge=age/factor

print('In', factor, 'years your age will be', finalAge, 'years old', userName)
print('Your age muliply by', factor, 'is', multAge)
print('Your age divided by', factor, 'is', divAge)

Compile and Execute Pascal Online

Program HelloWorld(output);
var
    okunan:string[50];
begin
  write('Input the infix expression:');
  read(okunan);
end.

Java example for inheritance with protected data member

class Papa{
    protected int x;
    Papa(){ x=40;}
    Papa(int y){x=y;}
}
public class son extends Papa
{
    protected int x=0;
    son(){super(15);}
    son(int x){ }
         public static void main(String []args)
         {
                son s = new son();
                System.out.println(s.x+" ");
                Papa t =new son(2);
                System.out.println(t.x);
     }
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.