CPP Tutorial

Hello World in different languages

Free Source Code

Free Source Code

Objectives :
* How to write Hello World in Java?
* How to write Hello World in C?
* How to write Hello World in PHP?
* How to write Hello World in C++?
* How to write Hello World in JavaScript?
* How to write Hello World in HTML?
* How to write Hello World in CSS?
* How to write Hello World in COBOL?

Java

[sourcecode language=”java”]
class HelloWorld
{
public static void main(String args[])
{
System.out.println(“Hello World!”);
}
}
[/sourcecode]

C

[sourcecode language=”c”]
#include
#include
void main()
{
clrscr();
printf(“Hello World!”);
getch();
}
[/sourcecode]

C++

[sourcecode language=”cpp”]
#include
#include
void main()
{
clrscr();
cout<getch();
}
[/sourcecode]

CSS

[sourcecode language=”css”]
body:before
{
content: “Hello World”;
}
[/sourcecode]

COBOL

[sourcecode language=”text”]
****************************
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
MAIN SECTION.
DISPLAY “Hello World!”
STOP RUN
****************************
[/sourcecode]

HTML

[sourcecode language=”html”]
<html>
<head>
<title>Hello World Example</title>
</head>
<body>
Hello World!
</body>
</html>
[/sourcecode]

JavaScript

[sourcecode language=”javascript”]
document.write("Hello World");
[/sourcecode]

PHP

[sourcecode language=”php”]
<!–?php echo ‘Hello World!’ ?–>
[/sourcecode]

Linux Shell Script

[sourcecode language=”text”]
echo "Hello World !"
[/sourcecode]

Enjoy coding!

Posted from WordPress for Android

Java Vs. C++

Objectives :

  • What are the differences between Java & C++?
  • What are the differences between C++ & Java?
  • Java Vs. C++

Java

C++

1. Java imports class files. 1. C++ includes header files.
2. Java doesn’t support “goto” statement. 2. C++ supports “goto” statement.
3. Java allows multi-level break & continue statements. 3. C++ doesn’t allows multi-level break & continue statements.
4. Java doesn’t support multiple inheritances but provides interfaces. 4. C++ supports multiple inheritances.
5. Java does not have destructors. 5. C++ has destructors.
6. Java supports auto garbage collection. 6. C++ does not supports auto garbage collection, requires memory management.
7. Java does not provide the facility of operator overloading. 7. C++ supports operator overloading.
8. Java neither supports RTI nor namespaces. 8. C++ supports RTI & namespaces.
9. Virtual (Dynamic dispatch) method is default. 9. Virtual method is needed to be implemented explicitly.
10. It is a platform independent language. 10. It is not a platform independent language.
11. “.class” file is generated after compilation. 11. “.exe” file is generated after compilation.
12. Java doesn’t support pointers. 12. C++ supports pointers.
13. Java doesn’t support Templates. 13. C++ supports Templates.
14. Java uses compiler & interpreter both. 14. C++ uses compiler only.
15. Java is far from hardware than C++. 15. C++ is more nearer to hardware than Java.
16. Java has primitive data type boolean. 16. In C++, boolean is not available.
17. Through Java we can develop Distributed / Internet based applications. 17. Development of Distributed / Internet based applications is not possible in C++.
18. Java can only pass by reference (well except primitives) 18. C++ can pass by value (default) or by reference.
19. Java posses 49 keywords including some reserved words. 19. C++ has 48 keywords. ANSI C++ has 15 more keywords.