COMPUTER PROGRAMMING FUNDAMENTALS
5 BASIC ELEMENTS OF PROGRAMMING
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
What is a correct syntax to output “Hello World” in C++?
|
Console.WriteLine("Hello World");
|
|
print("Hello World");
|
|
System.out.println("Hello World");
|
|
cout«"Hello World";
|
Explanation:
Detailed explanation-1: -1. a) The correct syntax to output “ Hello World” in C++ program is cout«” Hello World"; cout is used to display the message on the monitor.
Detailed explanation-2: -printf() is a library function to send formatted output to the screen. In this program, printf() displays Hello, World!
Detailed explanation-3: -class HelloWorld public static void main(String[] args) System. out. println("Hello World!"); // Hello World! The code in the example above will print “Hello World!” in the console.
Detailed explanation-4: -std::cout « “Hello World!"; std::cout prints the content inside the quotation marks. It must be followed by « followed by the format string. In our example, “Hello World!” is the format string.
There is 1 question to complete.