Sei sulla pagina 1di 12

DAY2

Features of OOPs
Emphasis is on data rather than procedures

Programs are divided into Objects


Data structures are designed such that they characterize objects Functions that operate on the data of an object are tied together in the data structures Data is hidden and cannot be accessed by external functions New data and functions can be easily added whenever required

Program No. 1 : Hello World

A C++ program starts with function called main ( ). The body of the function is enclosed between curly braces. The program statements are written within the braces.
Each statement must end by a semicolon;

#include <iostream.h>
The line in the above program that start with # symbol are called directives and are instructions to the compiler. The word include with '#' tells the compiler to include the file iostream.h into the file of the above program.

File iostream.h is a header file needed for input/ output requirements of the program. Therefore, this file has been included at the top of the program.

void main ( )
main() is an entry point of a program

When program is loaded in the memory, the control is handed over to function main ( ) and it is the first function to be executed.

cout<<"Hello World!";
This statement prints our "Hello World!" message on the screen. cout understands that anything sent to it via the << operator should be printed on the screen.

C++ Identifiers
A C++ identifier is a name used to identify a variable, function, class, module, or any other user-defined item.

An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores, and digits (0 to 9).

C++ Keywords
The following list shows the reserved words in C++. These reserved words may not be used as constant or variable or any other identifier names.
void Main public break else If class export new while private protected this for Switch try

Program No. 2 : Variable Declaration

Program No. 3 : Variable Declaration

Program No. 4 : Input Statement

Potrebbero piacerti anche