void main()
{
variable declarations; /* Statements define variables */
executable statements; /* Statements execute program */
}
As shown in the example, all C statements end with a semicolon. The function contains
two types of statements ± statements that define memory locations that will be used in the
program and statements that specify actions to be taken.
C.1.1 Variables and Assignment Operators
Before a variable can be used in a C program, it must be declared to inform the compiler
the name and type of the variable. A variable name is defined by declaring a sequence of
characters (the variable identifier or name) as a particular predefined type of data. C
constants are specific values that are included in the C statements, while variables are
memory locations that are assigned a name or identifier. The variable declaration uses
the following syntax:
data_type name;
For example, in the simple example we have
int k;
The term int indicates that the variable named k will store as integer data value. C also
allows multiple variables to be defined within one statement by separating them with the
commas. For example,
int i,j,k;
An identifier may be any sequence of characters (usually with some length restric-
tions) that starts with a letter or an underscore, and cannot be any of the C compiler
reserved keywords. Note that C is case sensitive; making the variable k different from
the variable K. C language supports several data types that represent: integers numbers,
floating-point numbers, and text data. Arrays of each variable type and pointers of each
type may also be declared and used. Once variables are defined to be a given size and
type, some sort of manipulation can be performed using the variables.
Memory locations must be defined before other statements use them. Initial values
can also be specified at the same time when memory locations are defined. For example,
int N 256;
defines the variable N as an integer, and assigns it with the value 256.
An assignment statement is used to assign a value to an identifier. The most basic
assignment operator in C is the single equal sign, =, where the value to the right of the
equal sign is assigned to the variable on the left. The general form of the assignment
statement is
identifier expression;
472
APPENDIX C: INTRODUCTION OF C PROGRAMMING FOR DSP APPLICATIONS