CPP Programming
About Lesson

Let us look at an example program of C++:

From the above program we can observe the following differences between C and C++.

  • cin, cout are new objects that are used manage i/o operations.  Instead of printf we are using cout and in the place of scanf we are using cin.  However, we can also use printf and scanf in C++.
  • If we want to use cin and cout, iostream.h header file to be included and stdio.h to be included if we want to use printf and scanf.
  • iostream.h is the header file which contains the declarations of identifiers cout, cin and operators << and >>.  In the latest IDEs #include<iostream> is only to be enetered without .h
  • cout represents the standard output stream (i.e. screen) and cin represents the standard input stream (i.e. keyboard)
  • << operator is called as insertion that can be used with cin object
  • put to >> operator is known as extraction or get from operator that can be used with cout object
  • Using cout, cin, >> and << for I/O operations is known as unformatted i/o means no format specifiers like %d, %f etc can be used. However, we can use printf and scanf functions for formatted I/O operations.
  • Multiple use of << operator is called cascading.
  • The main function should return an int value to operating system in C++.

You cannot copy content of this page