Output Operator
Output Operator
The statement cout <<”Hello, world” displayed the string with in quotes on
the screen. The identifier cout can be used to display individual characters,
strings and even numbers. It is a predefined object that corresponds to
the standard output stream. Stream just refers to a flow of data and
the standard Output stream normally flows to the screen display. The cout
object, whose properties are defined in iostream.h represents that stream.
The insertion operator << also called the ‘put to’ operator directs the
information on its right to the object on its left.
Return Statement:
In C++ main ( ) returns an integer type value to the operating system. Therefore every main ( ) in C++
should end with a return (0) statement, otherwise a warning or an error might occur.
Input Operator:
The statement cin>> number 1; is an input statement and causes The
program to wait for the user to type in a number. The number keyed in is
placed in the variable number1. The identifier cin is a predefined object in
C++ that corresponds to the standard input stream. Here this stream
represents the key board.
The operator >> is known as get from operator. It extracts value from the
keyboard and assigns it to the variable on its right.
cout<<”sum=”<<sum<<”\n”;
cout<<”sum=”<<sum<<”\n”<<”average=”<<average<<”\n”;
cin>>number1>>number2;