Introduction To C++ Language



C++ is a OOP language developed by Bjarne Stroustrup at AT & T Bell Laboratories in early 1980’s. He combined the features of C and  67 language and created a new language known as c++, initially as c++ was known as c with classes but later the name was changed to c++ in the year 1983.

Benefits of OOP:

Oop offer several benefits to both the program designer and the user. Object orientation contribute to the solution of many problem associated with the development and quality of software products. The new technology promises greater programmer productivity, better quality of software and lesser maintenance cost.

The Principal Advantage :

It is possible to map object int the problem domain in those in the program

It is easy to partition the work in a project based on objects.

Object-oriented system can be easily upgraded from small to large system

Software complexity can be easily managed

Through inheritance, we can eliminate redundant code and extend the use of existing classes

Message passing technique for communication between objects make the interface description with external system much simpler.

Application Of c++:

C++ s a versatile language for handling very larger programs. It is suitable for virtually any programming task including development of editors, compilers,data-bases,communication system and any complex business or real-life application systems.

Program in c++:

#include<iostream.h>//Header file for standard i/o operation.

void main(){

cout<<"c++ developed by Bjarne Stroustrup";

}

All c++ programs are similarly to c with some difference as,

Output operator:

cout<<"c++          is developed by Bjarne Stroustrup";

Display the string on the screen. This statement introduce two new c++ features, cout and <<.The identifier cout is a predefined object that represent the standard output stream in c++.The operator << is called as insertion or put to operator. It sends the content of the variable on the right to the object on its left.


The iostream file:

The declaration #include<iostream.h> cause the preprocessor to add the contents of the iostream file to program. It contain declaration for all the standard input/output operation.

Input operator:

The statement cin>> no1;is a statement used to accept input from the user in no1 variable .This statement introduce two new c++ feature, cin and c++.The operator >> is called as extraction or get from operator. It extract or take the value from the keyboard and assign it to the variable on its right.



Comments

c++ introduce a new comment symbol //.Comment start with a double slash symbol // and terminate at the end of the line. A comment may start anywhere in the line and whatever follows till the end of the line is ignored. Note that the there is no closing symbol.
The double slash comment is basically a single line comment. Multiline comment can be written as follows:
//This is an example of
//c++ program
The C comment symbols /*,*/ are still valid and more suitable for multiline comments. The following comment is allowed:
/*This is an example of
c++ program*/
Example:
Program 1:
#include<iostream.h>
void main(){
cout<<"Hello World";
}

Program 2:
#include<iostream.h>
void main(){
int workDays;
float workHours,payRate,weeklyPay;
workDays=5;
workHours=7.5;
payRate=38.55;
weeklyPay=workDays*workHours*payRate;
cout<<"Weekly Pay=";
cout<<weeklyPay;
cout<<"\n";
}

Program 3:
#include<iostream.h>
void main(){
double Fahrenheit;
double Celsius;
cout<<"Temperature in Fahrenheit";
Celsius =5*( Fahrenheit-32)/9;
cout<<Fahrenheit <<"degree Fahrenheit ="<<Celsius<<"degrees Celsius\n";
}