Total Pageviews

HELLO WORLD in different languages



ALGOL
:

BEGIN DISPLAY("HELLO WORLD!") END

.


APPLE SCRIPT :


say "Hello, world!"

ASSEMBLY LANGUAGE :


global main extern printf section .text main: push message call printf add esp, 4 ret message: db 'Hello, World', 10, 0

BASH ( UNIX SHELL) :


#!/bin/bash
STR="Hello World!"
echo $STR

BASIC :


10 PRINT "Hello,
World!"
20 END

C :


#include <stdio.h>
int main(void) {
printf("hello, world\n");
}

C++ :


#include <iostream>
int main() {
std::cout <<
"Hello, world!\n";
return 0;
}

C# :


using System;

class Program
{
static void Main(string args)
{
Console.WriteLine("Hello, world!");
}
}

Clojure :


(println "Hello world!")

COBOL
:

IDENTIFICATION DIVISION.
PROGRAM-ID. hello-world.
PROCEDURE DIVISION.
DISPLAY "Hello, world!"

CoffeeScript :


console.log "Hello, World!"

DART :


main() {
print('Hello World!');
}

FoxPro :


? "Hello World"

Object Pascal :


procedure TForm1.ShowAMessage;
begin
ShowMessage('Hello World!');
end;

GO :


package main

import "fmt"

func main() {
fmt.Println("Hello, World")
}

RUBY :


println "Hello World"

HASKELL :


module Main where

main :: IO ()
main = putStrLn "Hello, World!"

JAVA :


class HelloWorldApp {
public static void main(String args) {
System.out.println("Hello World!"); // Prints the string to the console.
}
} strong>JAVASCRIPT :

console.log("Hello World!");

MACHINE CODE :


b8 21 0a 00 00 #moving "!\n" into eax
a3 0c 10 00 06 #moving eax into first memory location
b8 6f 72 6c 64 #moving "orld" into eax
a3 08 10 00 06 #moving eax into next memory location
b8 6f 2c 20 57 #moving "o, W" into eax
a3 04 10 00 06 #moving eax into next memory location
b8 48 65 6c 6c #moving "Hell" into eax
a3 00 10 00 06 #moving eax into next memory location
b9 00 10 00 06 #moving pointer to start of memory location into ecx
ba 10 00 00 00 #moving string size into edx
bb 01 00 00 00 #moving "stdout" number to ebx
b8 04 00 00 00 #moving "print out" syscall number to eax
cd 80 #calling the linux kernel to execute our print to stdout
b8 01 00 00 00 #moving "sysexit" call number to eax
cd 80 #executing it via linux sys
call

MATLAB :


disp('Hello, World')

ML :


print "Hello world!\n";

NODE.JS :


console.log("Hello World!");

OBJECTIVE-C :


main()
{
puts("Hello World!");
return 0;
}

PASCAL :


program
HelloWorld(output);
begin
Write('Hello, world!')
end.

PERL :


print "Hello,
World!\n";

PHP :


<?php echo "Hello, World";

POWERSHELL :


Write-Host "Hello, World!"

PYTHON :


print("Hello World")

R :


cat("Hello world\n")

RPG :


dcl-s wait char(1);

dsply ( 'Hello World!') ' ' wait;



inlr =
on;

RUBY :


puts 'Hello World!'

SCRATCH :


say Hello, World!

SWIFT :


println("Hello, world!")

TYPESCRIPT :


console.log("Hello World!");

Java
:
import java.util.Scanner;
import java.io.*;
class Calculator
{
public static void main(String[] args)
{
int choice;
int x = 0;
int y = 0;
int sum;
PrintStream out;
Scanner input;
Calculator calc = new Calculator();
try
{
out = new PrintStream("calclog.txt");
do
{
System.out.println("Calculator Program"); System.out.println("--------------------\n");
System.out.println("1. Add");
System.out.println("2. Subtract");
System.out.println("3. Multiply");
System.out.println("4. Divide");
System.out.println("5. Mod");
System.out.println("6. Power");
System.out.println("99. End Program\n");
System.out.println("Enter Choice: ");
input = new Scanner(System.in);
choice = input.nextInt();
while ((choice < 1 || choice > 6) && choice != 99)
{
System.out.println("Please enter 1, 2, 3, 4, 5, or 6: ");
choice = input.nextInt();
}
if (choice != 99)
{
System.out.println("Please enter 2 numbers only: ");
x = input.nextInt();
y = input.nextInt();
}
switch (choice)
{
case 1:
sum = calc.add(x, y);
System.out.printf("The sum is %d\n\n", sum);
out.println(x + "+" + y + "=" + sum);
break;
case 2:
sum = calc.sub(x, y);
System.out.printf("The answer is %d\n\n", sum);
out.println(x + "-" + y + "=" + sum);
break;
case 3:
sum = calc.multi(x, y);
System.out.printf("The answer is %d\n\n", sum);
out.println(x + "" + y + "=" + sum);
break;
case 4:
try
{
sum = calc.div(x, y);
System.out.printf("The answer is %d\n\n", sum);
out.println(x + "/" + y + "=" + sum);
}
catch (Exception e)
{
System.out.println("\nError: Cannot Divide by zero\n\n");
}
break;
case 5:
sum = calc.mod(x, y);
System.out.printf("The mod is %d\n\n", sum);
out.println(x + "%" + y + "=" + sum);
break;
case 6:
sum = calc.pow(x, y);
System.out.printf("The answer is %d\n\n", sum);
out.println(x + "^" + y + "=" + sum);
break;
}
}
while (choice != 99);
input.close();
System.out.println("Ending program...");
}
catch (Exception e){
System.out.println("ERROR: Some error occured");
e.printStackTrace();
}
}
public int add(int num1, int num2)
{int sum;
sum = num1 + num2;
return sum;
}
public int sub(int num1, int num2)
{ int sum;
sum = num1 - num2;
return sum;
}
public int multi(int num1, int num2)
{ int sum;
sum = num1*num2;
return sum;
}
public int div(int num1, int num2)
{int sum;
sum = num1 / num2;
return sum;
}
public int mod(int num1, int num2)
{int sum;
sum = num1 % num2;
return sum;
}
public int pow(int base, int exp)
{int sum = 1;
if (exp == 0)
{sum = 1;
}
while (exp > 0)
{sum = sum*base;
exp--;
}
return sum;
}
}
@codingworld

C language
:


Program to swap two strings
.

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>

void main()
{
char str1100, str2100,

temp;
clrscr();

printf("Enter first string : ");
gets(str1);

printf("Enter second string : ");
gets(str2);

printf("\nBefore Swapping : \n");
printf("First string : %s\n", str1);
printf("Second string : %s\n", str2);

temp = (char
) malloc(100);

strcpy(temp, str1);
strcpy(str1, str2);
strcpy(str2, temp);

printf("\nAfter Swapping : \n");
printf("First string : %s\n", str1);
printf("Second string : %s\n", str2);
getch();
}
@codingworld

C language :
Program to calculate the length of string without using strlen() function.


#include<stdio.h>
#include<conio.h>

void main()
{
char s[1000], i;
clrscr();

printf("Enter a string : ");
scanf("%s", s);


for (i = 0; si != '\0'; ++i);

printf("Length of string : %d", i);
getch();
}
@codingworld

Java :
Program to Find Harmonic Series.


import java.util.*;

class HarmonicSeries
{

public static void main(String args[])
{

int num, i = 1;
double rst = 0.0;

Scanner in = new Scanner(System.in);
System.out.println("Enter the number for length of series");
num = in.nextInt();

while (i <= num)
{

System.out.print("1/" + i + " +");
rst = rst + (double) 1 / i;

i++;
}

System.out.println("\n\nSum of Harmonic Series is " + rst);
}
}

@codingworld

C++ :
Program to Display upper half of matrix.


#include<iostream>

using namespace std;

//method declaration
void upper_halfofmatrix(int mat[10][10], int col, int r);

int main()
{
//variable declaration
int mat[10][10], row, col, i, j;
//input for row and column
cout << "enter how many numbers of row and column you want : ";
cin >> row >> col;
//enter element into matrix
cout << "enter elements: \n";

for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
cin >> mat[i][j];
}
}
upper_halfofmatrix(mat, col, row);

return 0;
}

//method definition
void upper_halfofmatrix(int mat[10][10], int col, int row)
{
int i, j;

for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
if (i <= j)
cout << mat[i][j];

else
cout << " ";
}

cout << "\n";
}
}
@codingworld

Java:
Number pattern 5.

12345
1234
123
12
1
12
123
1234
12345


class NumberPat5
{

public static void main(String arg)
{

int ck = 0, c = 2;

while (c > 0)
{

if (ck == 0)
{

for (int i = 1, r = 5; i <= 5; i++, r--)
{

for (int j = 1; j <= r; j++)
{

System.out.print(j);

}

System.out.println();

}

ck++;

}
else
{

for (int i = 2; i <= 5; i++)
{

for (int j = 1; j <= i; j++)
{

System.out.print(j);

}

System.out.println();
}
}

c--;
}

}
}

@codingworld

C language :



Program to calculate the determinant of 2×2 matrix.


#include<stdio.h>
#include<conio.h>

void main()
{
int a22, i, j;
long determinant;
clrscr();

printf("Enter the 4 elements of matrix :\n");
for (i = 0; i < 2; i++)
{
for (j = 0; j < 2; j++)
{
scanf("%d", &aij);
}
}

printf("\nThe matrix is : \n");
for (i = 0; i < 2; i++)
{
printf("\n");
for (j = 0; j < 2; j++)
{
printf("%d\t", aij);
}
}

determinant = a00

a[1][1] - a[1][0]
a01;

printf("\nDeterminant of 2X2 matrix: %ld", determinant);

getch();
}
@codingworld

Do you like our channel?

Comment below what you are expecting from our channel


Python:



RAINBOW Benzeneu

import turtle
colors=['red','purple','blue','green','orange','yellow']
t=turtle.Pen()
turtle.bgcolor('black')
for codingworld in range(360):
t.pencolor(colors[codingworld %6])
t.width(codingworld/100 + 1)
t.forward(codingworld)
t.left(59)

@codingworld

No comments:

Post a Comment

Thank you