C++ Simple Program tutorial BCAStudy

Ashutosh Kumar
By -
0
Simple Hello world programme in c++ programming language


Hi, IGNOU BCA Reader.

In this post We will create simple "Hello World" program in C++ Programming Language.

This simple Hello World program that will print Hello World greeting to your terminal.


#include <iostream.h>
using namespace std;

int main(){
 cout<<"Hello World";
 return 0;
}

 

Explanation :

#include <iostream.h> 

This include statement is pre-processor. Which includes the input/output function to your program. Just like in C program we include the <stdio.h> in every c program. In which predefined printf() is for standard output.

 

using namespace std; ( Class declaration so it member function can be used)

It is helpful because we don't have to write the much like std.<member or function> every time. In c++ program the standard function or predefined members/function are used more over repeatedly. When we use this syntax, it member function became available to globe. 

All the elements of standard ANSI C++ library are declared within namespace std;


main()

This is function from where the execution of the code start. It is essential that all c++ program have a main function.

The main function have number of variant/way/alternative to declare accordingly. Latter we will discuss.


Your code 

Whatever function or command you write in body of main function is get execution on runtime.

cout << "Hello World";

This line is a C++ statement. cout is the name of the standard output stream in c++, It is used to insert a sequence to characters in standard output ( For now. Our terminal is that). cout is declared in the iostream.h header file with the std namespace.


semicolon character (;) is used to tell (what?) that here is end of statements. And it must be include at end of all statement in C++ program.


return 0; 

It indicates that main function to be finished as this statement executed.



Post a Comment

0Comments

✍️ Only article/post centric comments are allowed.
❌**No Spam**
❌**Advertisement**
❌**No abuse**
Rules strictly applied ✅

Post a Comment (0)