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.

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.






To learn more you can just click the below topics:

C++

INTRODUCTION OF C++ || Definition of C++
Brief history of C++ || history of C++
Features of C++ || why we use C++ || concept of C++
Concept of OOP || What is OOP || Object oriented programming language
Difference Between OOP And POP || Different Between C and C++
Characteristics of C++
Interesting fact about C++ || Top 10 interesting fact about C++
C++ Program Structure
Basic Data Type And Variable In C++
Identifier in C++
Keywords in C++
Token in C++
Comment in C++
Constant in C++
Modifier in C++
Taking User Input in C++ | User input in C++
Input Output Operator In C++
C++ Operators | Operator in programming language
How to Add two number in C++
Polymorphism in C++
Compile Time Polymorphism in C++
Function overloading in C++
Operator Overloading in C++
What are Control Structures in C++ || Understanding Control Structures in C++ | How to use if, else, switch
What are Functions and Recursion in C++ | How to Defining and Calling Functions

Class in C++
Object in C++

Data Science

The History and Evolution of Data Science
Scope of Data Science
Why learn Data Science? | Why Data Science?
Impact of Data Science
The Importance of Data in Science | Introduction to Data Science
What is Data Analysis | Data Analyst for Beginners

Algorithm

Why algorithm | The Importance of Algorithms in Modern Technology

Tech to know

Which is better | BSc in Computer Science or BTech?

Post a Comment

Ask any query by comments

Previous Post Next Post