You have seen the basic structure of a C program, so it will be easy to understand other basic building blocks of the C programming language.
A C program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol. In C programming program is a collection of tokens that are keyword,a literal,a symbol or constant value.
There are 32 keyword are reserved. The following list shows the reserved words in C:-
Tokens | Tokens | Tokens | Tokens |
---|---|---|---|
int | struct | auto | double |
break | else | static | while |
if | do | sizeof | volatile |
default | goto | signed | void |
continue | for | unsigned | short |
float | const | union | return |
char | typedef | register | enum |
switch | long | case | extern |
An identifier is nothing but a name assigned to an element in a program. For example,the name of a variable, function, etc. Identifiers are the user-defined names consisting of 'C' standard character set. As the name says, identifiers are used to identify a particular element in a program. Each identifier must have a unique name.
The following rules must be followed for identifiers:
Constants are those values that cannot be changed during program execution.
There are 32 keyword is reserved. The following list shows the reserved words in C.
Syntaxconst type constant_name;
#include<stdio.h> main() { int side = 10; int area; area = side*side; printf("The area of the square:%d",area); }
A string in C is merely an array of characters. The length of a string is determined by a terminating null character: '\0'. So, a string with the contents, say, "abc" has four characters: 'a', 'b', 'c', and the terminating null ('\0') character.
The terminating null character has the value zero.
char c[] = "abcd";
The following special symbols are used in C having some special meaning and thus, cannot be used for some other purpose.
Symbol | Meaning |
---|---|
~ | Tilde |
# | Number sign |
! | Exclamation mark |
$ | Dollar sign |
% | Percent sign |
^ | Caret |
& | Ampersand |
* | Asterisk |
{} | brace |
: | Colon |
; | Semi-Colon |
C operators are symbols that trigger an action when applied to C variables and other objects. The data items on which operators act upon are called operands.
Those operators that require only a single operand to act upon are known as unary operators.
Those operators that require two operands to act upon are called binary operators
Escape sequence:- | Meaning |
---|---|
\n | New line |
\a | Alarm |
\t | Carriage Return |
\b | backspace |
\t | Tab(Horizontal) |
\v | Vertical Tab |
\\ | Backslash |
\0 | Null |
\? | question Marks. |
\nnn | Octal number |
\xhh | Hexadecimal number |