Examples of variables in c++ Programming

0

variable is a container (storage area) to hold data

Example :

int age = 14;

All Contributions

String Literals :

A string literal is a sequence of characters enclosed in double-quote marks. For example:

 

"good" : string constant

" " : null string constant

"   " : string constant of six white space

"x" : string constant having a single character

"Earth is round\n" : prints string with a newline

Escape Sequences

Sometimes, it is necessary to use characters that cannot be typed or has special meaning in C++ programming. For example, newline (enter), tab, question mark, etc.

In order to use these characters, escape sequences are used.

Escape Sequences Characters

\b : Backspace

\f : Form feed

\n : Newline

\r : Return

\t : Horizontal tab

\v : Vertical tab

\\ : Backslash

\' : Single quotation mark

" : Double quotation mark

\? : Question mark

\0 : Null Character

Characters

A character literal is created by enclosing a single character inside single quotation marks. For example:

'a', 'm', 'F', '2', '}' etc.

 Floating-point Literals:

A floating-point literal is a numeric literal that has either a fractional form or an exponent form. For example: 

-2.0

 

0.0000234

 

-0.22E-5

 Integers:

An integer is a numeric literal(associated with numbers) without any fractional or exponential part. There are three types of integer literals in C programming:

 

decimal (base 10)

octal (base 8)

hexadecimal (base 16)

For example:

Decimal: 0, -9, 22 etc
Octal: 021, 077, 033 etc
Hexadecimal: 0x7f, 0x2a, 0x521 etc

total contributions (5)

New to examplegeek.com?

Join us