Statements in C++

An executable instruction is known as a statement. They can classified into two main categories:

Simple statements or expression statements.

Complex statements(Control statements: next chapter).

1) Expression Statements:

Any expression ending with a semi-colon (;) is known as an expression statement. For e.g.:

a=b;

A=5;

a=b+c;

a++;

Input statement:

'cin' is an object(variable) declared in 'iostream.h' header file that represents the standard input device i.e. keyboard. This variable together with >> (extraction operator here) can be used for reading the value of a variable from the keyboard.
Syntax:

cin>>variable_name; --> this is an expression.
cin>>variable_name; --> this is a statement known as input statement.

Character constants --> Any character within ' ' is a character constant.

E.g.: 'A', 'b', '6', '+'.

String constants --> Any sequence of characters within " " is known as a string.

E.g.: "Hello world", "12+152".

Output statement:

'cout' is an object that represents the standard output device i.e. monitor. Using cout together with << (insertion operator here), we can display the value of a variable or a constant or an expression.
Syntax:
cout< This is an expression.
cout< This is a statement known as output statement.

cout<
output --> hello

cout<
cout<
output --> HelloHello

cout <
cout<
output-->Hello
Hello

Note -->'\n' is a special character constant known as new line character that brings the cursor to the next line.

About Us!

'Z Series Innovations' is an e-learning solution for learning all technical stuff online. It is an online portal that gives an enhanced way of learning and guidance in various fields of engineering which include robotics, electronics, communication,computer science, embedded systems and its real life applications.

Join Us

Do you feel like contributing to this website technically? Jump in!

Your technical expertise would be needed to create quality articles and content on this site and hence contribute to this growing global community of technical enthusiast.