C++ 01: Introduction to C++

Introduction 

C++ was developed by Bjarne Stroustrup at Bell Laboratories over a period starting in 1979. Since C++ is an attempt to add object-oriented features (plus other improvements) to C, earlier it was called as “C with Objects”. As the language developed, Stroustrup named it as C++ in 1983.

C++ Program Structure

Preprocessor Commands            ---->Header Files
global declaration                        ---->Global Variables
main()
{
        ......
        ......
}

#include --> Provide Header files to the compilers
#define  -->  Used to define macros.

Console Input Output Objects

cout - <<Insertion Operator to print on screen
cin -   >>Extraction Operator to take input

Simple Program to Demonstrate :

#include<iostream>
using namespace std;

main(){

    cout<<"Welcome to C++ \n";
    cout<<"Tutorial on C++"<<endl;
    
}

Important Terms:

Function/Object

Descript

cout

The Object cout is used with an insertion operator (<<) to send and recive a message or output of a program or a value of a variable to screen.

In simple words, cout is used to display any message or standard output to the screen. This object is available in the header file <iostream.h>

Syntax:

  •           cout<<”message”;
    • cout<<variable_name;

cin

The object cin is used within an extraction operator (>>) to read the input entered from the keyboard by the user and place the data in the appropriate variable. This object is available in the header file <iostream.h>

Syntax:

·        cin>>variable1>>variable2>>..;

void clrscr();

This function is used to clesr the screen output. It is defined in the conio.h header file.

int getch();

This function get’s a charcter from console. It is defined in the header file conio.h

“\n” or <<endl;

It print a new line characters. In simple words we can say that it encounters an end of line.







 

Comments

Popular posts from this blog

C++ 38: Visibility Modes Public, Private and Protected