First program in C++ || how to write hello world in C++ || Writing first program in C++

 

First program in C++ ||  hello world in C++ 

 Our program's first line is a comment line. Every line that begins with two slash signs (//) is regarded as a comment and has no influence on the program's behavior or conclusion. (Words between /* and */ are also treated as comments (old-style comments). Use comments to clarify challenging aspects of your scripts, but don't go overboard. It is also customary to begin each program with a quick overview of what the program will perform.

First program in C++



{tocify} $title={Table of Contents}

In the below program we are not using (using namespace std;)

 

// C++ program to display "Hello World"

// Header file for input output functions

#include <iostream.h> 

#include <conio.h>

// Main() function: where the execution of

// program begins

void main()

{

// Prints hello world

cout<<”Hello world”;

getch();

}

 

Output:-

Hello world

 

<iostream.h>

The header file <iostream.h> is input output stream, it is use to control the input output operation in C++ language.

<conio.h>

Another header file <conio.h> is console input output, it is used in an old DOS compilers to create text user interfaces.

 

Void main()

Void: is a keyword in c++ language, void means nothing, whenever we use void as a function return type then that function nothing return. here main() function no return value.

 

There must be a main() function in every program. The execution of all C++ programs begins at the main function. There are two circular brackets after the word main. This is due to the fact that it is a function declaration (a subsequent blog will go into more depth about functions). Within the round brackets, you can encapsulate a list of parameters.

 

{}

The beginning and end of the function main are denoted by the two curly brackets (one at the beginning and one at the end). Also known as the function's body. When the function is called and performed, it executes everything that is written between these curly brackets.

 

cout << “Hello World”;

 

In C++, the standard output stream is represented by cout.

(There is also a standard input stream Read more). A series of characters (Hello World) will be sent to the standard output stream (in most situations, your screen).

The words Hello World must be placed between " ", however the " " will not be printed on the screen. They indicate where the sentence begins and where it will stop.

 

getch();

It is a function that use to hold the output screen until the user passes a key from the keyboard to exit the screen.


Data science & data analyst

C++

Algorithms

Technology



Post a Comment

Ask any query by comments

Previous Post Next Post