CodesJava

Easy learning with example program codes

CPP Example


Lets print “Hello CPP” as the first CPP program and than understand it in detail.

#include <iostream.h>
#include<conio.h> 
void main()
{
clrscr();  
cout <<"Hello CPP!";
getch(); 
}

Output

Hello CPP!

Description:

#include <iostream.h> :

“#include” is a preprocessor directive used to include a library file in the code. The header file “iostream.h” is included in the source code to use the pre-defined functions “cin” and “cout”.

#include <conio.h>: The header file “conio.h” is included in the source code to use the pre-defined functions “getch”.

void main() :

Void represents the data type of the main function which is a must for every C program.

{} :

{} represents the opening and closing of the main function.

cout<<“Hello C!”; :

The cout function outputs the string on the console screen.

getch():

The getch() function is used to block the screen till any key is pressed. It simply asks for a single character.

Compilation and Execution:

Click on Compile menu and then on Run menu or click ctrl+F9 directly, both for compile and run.

Posted in CPP   
Sign Up/ Sign In
Ask a Question


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki