First program in C++

Cpp is an Object oriented language (OOpl). It was developed in 1980 at BELL Laboratories. It is improved version of C language. It provides the facility of working with objects and classes. It is very powerful language and is used to develop a variety of program.
Here is the First program with screen shot in Borland C++ . You can use any Software like Visual Studeo, codeBlock etc and whatever you like. The main purpose is practice to get success. Rbatec provide you a platform to learn Cpp.
C++ is close to human langauges that’s why this is called High Level Language.
#include<Iostream.h>
#inlcude<conio.h>
Int main

{
Cout<<”welcome to c++”<<endl;
Getch ( );
Return 0;
}
First program in Cpp
First Program in Cpp

Preprocessor Directive (#)

Instruction given to Compiler before the execution of actual program. The preprocessor Directive start with hash symbol #.
Include Preprocessor
Include preprocessor directive include header file in cpp program.
Example #include<iostream>
Header File
It is the collection of library function to perform different tasks.
Syntax of Header file
#inlcude<header_file_name>
Example
#include<iostream>
“Iostream” is stands for input output stream.
Main Function
The main function () is the initial line of CPP Program. When the program is run, the control enters main() function and start executing its statements.
Syntax of Main Function
Void main
{
Body of main dunction.
}

Body of program
In the above first cpp program the body is (cout<<”welcome to c plus plus”;).
In Double quotes the Line is displayed on screen. You can display any this on screen like your name .
Example cpp
Cout<<”I m visiting RBatec blog”; etc
In above c++ first program
The first line is preprocessor Directive to include a header File iostream.h.
The secong line in main function where the execution of program starts.
Return 0;
Main function should always return 0.its mean Main fuction () ran fine.
You can run this program in Borlan Cpp by using short Command ctrl+f9.

Reference Book: Object Oriented Programming Using C++

Post a Comment

Previous Post Next Post