Escape Sequences:
- Escape Sequences are used to format the output from a print function.
- The escapes sequences are character literals or character constants.
- Every escape sequence character starts with a backward slash(\)
- Though it is a combination of \ and another letter (two characters), it is treated as a single character.
Escape Sequences in C
Character |
Name |
Use |
\n |
New line |
Move the cursor to next line |
\t |
Tab Space |
Insert a single Tab Space |
\a |
Alert |
Generates a Beep Sound |
\b |
Back Space |
Cursor is moved one character back |
\r |
Carraige Return |
Cursor moved to starting of the same line |
\\ |
Forward Slash |
Insert a single \ |
\" |
Double quote |
Insert a single " |
Data Types and Format Specifiers:
Variable:
- Variable is defined to be named memory location
- A single variable can hold a single data value only
- If the variable is already having a value an a new value is given, then the new value replaces the old value.
- Variable named should be chosen by the programmer and should obey identifier rules (Ref Chap-1 Introduction to C)
Data Types:
- The data type is defined to be a keyword that defines the type of data that a variable can hold.
- The flow chart below gives a clear view of data types in C:
System Defined Data Types
Name |
Keyword |
Format Specifier |
Memory |
Range |
Void |
void |
--- |
0 bytes |
Nothing |
Character |
char |
%c |
1 byte |
Any Ascii Character |
Integer |
int |
%d |
2 bytes |
-32768 to 32768 |
Float |
float |
%f |
4 bytes |
3.4*10^-38 to 3.4*10^38 |
Double |
double |
%lf |
8 bytes |
1.7*10^-308 to 1.7*10^308 |
Type Qualifiers:
Type Qualifier is a special keyword that can control the basic data to an increased range or to a decreased range slightly.
0 Comments