You are currently viewing How to Print “Hello World!” in Different Programming Languages – C, C++, JavaScript, PHP, and Python

How to Print “Hello World!” in Different Programming Languages – C, C++, JavaScript, PHP, and Python

Have you ever wondered how to print “Hello World!” in different programming languages? “Hello World!” is the first program for any programmer to learn and understand the basics of the language. Today, I am going to explain how to print “Hello World!” in C, C++, JavaScript, PHP, and Python.

C: In C programming language, you need to include the standard input/output library and use the printf() function to display the string. The entry point of the C program is main() and you can use it to call the printf() function.

#include <stdio.h>
int main()
{
    printf("Hello World!");
    return 0;
}

//This code prints "Hello World!" by including the standard input/output library, main() is the entry point of the C program and printf() is used to display the string "Hello World!".

C++: In C++ programming language, you need to include the input/output library and use the cout function to display the string. The entry point of the C++ program is main() and you can use it to call the cout function.

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

//This code prints "Hello World!" by including the input/output library, main() is the entry point of the C++ program and cout is used to display the string "Hello World!".

JavaScript: In JavaScript, you need to use the console.log() method to print the string.

console.log("Hello World!");

//This code prints "Hello World!" by using the console.log() method which is used to print the given string on the console.

PHP: In PHP, you need to use the echo statement to print the string. Python: In Python, you need to use the print() function to print the string.

<?php
echo "Hello World!";
?>

//This code prints "Hello World!" by using the echo statement which is used to print the given string on the screen.

Python: print(“Hello World!”) //This code prints “Hello World!” by using the print() function which is used to print the given string on the console.

print("Hello World!")

//This code prints "Hello World!" by using the print() function which is used to print the given string on the console.

So, now you know how to print “Hello World!” in C, C++, JavaScript, PHP, and Python. I hope this blog post has helped you understand the basics of different programming languages.

Er Kumar Anup

Website Developer Mentor and Learner

Leave a Reply