C langugae : Language Basics

Character Sets The basic source and execution character sets both contain the following types of characters:
The letters of the Latin alphabet
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
a b c d e f g h i j k l m n o p q r s t u v w x y z
The decimal digits
0 1 2 3 4 5 6 7 8 9
The following 29 punctuation marks
! " # % & ' ( ) * + , - . / : ; < = > ? [ \ ] ^ _ { | } ~
The five whitespace characters
Space, horizontal tab, vertical tab, new line, and form feed
Each character in the basic character set must be representable in one byte.
The null character is a byte in which all bits are 0.
The value of each decimal digit after 0 is greater by one than that of the preceding digit.
Digraphs
C provides alternative representations for a number of punctuation marks that are not available on all keyboards .
Digraph Equivalent
<: [
:> ]
<% {
%> }
%: #

Example With digraphs: -
int arr<::> = <% 10, 20, 30 %>;
printf( "The second array element is <%d>.\n", arr<:1:> );
Without digraphs: -
int arr[ ] = { 10, 20, 30 };
printf( "The second array element is <%d>.\n", arr[1] );
Trigraphs
C also provides trigraphs , three-character representations, all of them beginning with two question marks. The third character determines which punctuation mark a trigraph represents.
Trigraph Equivalent
??( [
??) ]
??< {
??> }
??= #
??/ \
??! |
??' ^
??- ~

Trigraphs allow you to write any C program using only the characters defined in ISO/IEC 646, the 1991 standard corresponding to 7-bit ASCII . The compiler's preprocessor replaces the trigraphs with their single-character equivalents in the first phase of compilation.
Identifiers
The term identifier refers to the names of variables, functions, macros, structures and other objects defined in a C program. Identifiers are case-sensitive.It contains universal character names that represent the letters and digits of other languages.keywords are reserved in C,and must not be used as identifiers.
double a = 0.5;
Keywords
Keywords are reserved in C, Which have a specific meaning to the compiler. The following keywaord are given below: - auto, enum, restrict, unsigned, break, extern, return, void, case, float, short, volatile, char, for, signed, while, const, goto , sizeof, _Bool, continue, if, static, _Complex, default, inline, struct, _Imaginary, do, int, switch, double, long, typedef, else, register, union
Tokens
A token is either a keyword, an identifier, a constant, a string literal, or a symbol. Symbols in C consist of one or more punctuation characters, and function as operators or digraphs, or have syntactic importance, like the semicolon that terminates a simple statement, or the braces { } that enclose a block statement. For example, the following C statement consists of five tokens:
printf
(
"Hello, world.\n"
)
;
Literals
A literal is a token that denotes a fixed value, which may be an integer , a floating-point number, a character, or a string. A literal's type is determined by its value and its notation.

Statements
A statement specifies one or more actions to be performed, such as assigning a value to a variable, passing control to a function, or jumping to another statement.Jumps and loops are statements that control the flow of the program. Except when those control statements result in jumps, statements are executed sequentially; that is, in the order in which they appear in the program.
A compound statement, called a block for short, groups a number of statements and declarations together between braces to form a single statement
Escape Sequences
Escape sequence Character value Action on output device
\' A single quotation mark (') Prints the character
\" A double quotation mark (")    
\? A question mark (?)    
\\ A backslash character (\)    
\a Alert Generates an audible or visible signal
\b Backspace Moves the active position back one character
\f Form feed Moves the active position to the beginning of the next page.
\n Line feed Moves the active position to the beginning of the next line.
\r Carriage return Moves the active position to the beginning of the current line
\t Horizontal tab Moves the active position to the next horizontal tab stop
\v Vertical tab Moves the active position to the next vertical tab stop
\o, \oo, or \ooo
(where o is an octal digit)
The character with the given octal code Prints the character
\xh[h...]
(where h is a hexadecimal digit)
The character with the given hexadecimal code    
\uhhhh
\Uhhhhhhhh
The character with the given
universal character name
   

Block Statements
A compound statement, called a block for short, groups a number of statements and declarations together between braces to form a single statement. Block statements are not terminated by a semicolon. A block is used wherever the syntax calls for a single statement, but the program's purpose requires several statement For Example: -.
{ double result = 0.0, x = 0.0; // Declarations
static long status = 0;
extern int limit;
++x;        // Statements
if ( status == 0 )
{        // New block
int i = 0;
while ( status == 0 && i < limit )
{ /* ... */ }        // Another block
}
else
{ /* ... */ }         // And yet another block
}
Preprocessing Directives
The C compiler preprocesses every source file before performing the actual translation. The preprocessor removes comments and replaces macros with their definitions.
Every preprocessing directive appears on a line by itself, beginning with the character #. If the directive is long, it can be continued on the next line by inserting a backslash (\) as the last character before the line break
. #define
The #define directive is used to define macros
#define SIZE 512      // Symbolic constant
The # Operator
In the macro replacement text, the parameters of the macro may be preceded by the operator # (called the hash or stringizing operator). In this case, the preprocessor sets the corresponding argument in quotation marks, thus converting it into a string.
#include
The #include directive instructs the preprocessor to insert the contents of a specified file in the program at the point where the #include directive appears.
#include
#include "filename"
#include "project.h"
If the filename is enclosed in angle brackets, the preprocessor only searches for it in certain directories. These directories are usually named in the environment variable INCLUDE.
If the filename is enclosed in quotation marks, the preprocessor first looks for the file in the current working directory.
The filename may contain a directory path. In this case, the file is only looked for in the specified directory.
The files named in include directives are generally "header" files containing declarations and macro definitions for use in several source files, and have names ending in .h. Such files may in turn contain further #include directives.
Standard Header Files
All function prototypes, macros, and types in the ANSI library are contained in one or more of the following standard header files:
assert.h, inttypes.h(*), signal.h, stdlib.h, complex.h(*), iso646.h(*), stdarg.h, string.h, ctype.h, limits.h, stdbool.h(*), tgmath.h(*), errno.h, locale.h, stddef.h, time.h, fenv.h(*), math.h, stdint.h(*), wchar.h(*), float.h, setjmp.h, stdio.h, wctype.h(*)
Conversion Specifiers and the Resulting Printed Output

Conversion Specification

Output

%a

Floating-point number, hexadecimal digits and p-notation (C99).

%A

Floating-point number, hexadecimal digits and P-notation (C99).

%c

Single character.

%d

Signed decimal integer.

%e

Floating-point number, e-notation.

%E

Floating-point number, e-notation.

%f

Floating-point number, decimal notation.

%g

Use %f or %e, depending on the value. The %e style is used if the exponent is less than –4 or greater than or equal to the precision.

%G

Use %f or %E, depending on the value. The %E style is used if the exponent is less than –4 or greater than or equal to the precision.

%i

Signed decimal integer (same as %d).

%o

Unsigned octal integer.

%p

A pointer.

%s

Character string.

%u

Unsigned decimal integer.

%x

Unsigned hexadecimal integer, using hex digits 0f.

%X

Unsigned hexadecimal integer, using hex digits 0F.

%%

Prints a percent sign.



Free Web Hosting