In this tutorial you will learn about the C++ Program to Print Hello World and its application with practical example.
C++ Program to Print Hello World
In this tutorial, we will learn to create a C++ program that will Print Hello World in C++ programming.
Prerequisites
Before starting with this tutorial we assume that you are best aware of the following C++ programming topics:
- Operators in C++ Programming.
- Basic Input and Output function in C++ Programming.
- Basic C++ programming.
Printing a message:-
Message passing is a very important feature for object-oriented programming. Here in this program, we will print the message to the user for hello world.
Algorithm to Print Hello World in the output:-
1 2 3 4 5 6 7 |
1. Declaring the variables for the program. 2. Definig the input value for the variable in String format. 3. Printing the data taken in input from the user in String format. 4. End program |
Program to Print Hello World
The string is a collection of characters in c++ programming. The string is used for sending messages on the screen. In c++ programming, we can take the input from the user in string format. In this program, we will define input in string format. The second will print the string “Hello World” with the help of a small program. The String is the most useful datatype in any programing language.
Program to Print Hello World:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
/* C++ Program to Print Hello World */ #include <iostream> using namespace std; int main() { /* variable definition and initialization for the program*/ //strary will store the string value for the program char strary[100]="Hello World"; cout<<endl; /* Printing the output for the string defined in to a variable in the program with out taking input from the user */ cout << "You enter the string:"<< endl << strary << endl; return 0; } |
Output:-
In the above program, we have first initialized the required variable.
- strary = it will hold the input string value from the user.
Printing the data in the output in the string format.
The Program Code for the main method.