Faculty Supervisor: Al Day
Some material is derived from a lesson by: Prof. Martha Selby
HTML documentation by: Michelle Roberts
Last updated 8/16/95
e.g. int n; /* declare n to be of type int */
/* now the looping process will begin */
for (n=0; n<5; n++) { printf("Oh yah.\n"); } /* end of looping process*/
Include statements are used as follows:
These statements cause the preprocessor to replace the #include
statement with the code from the corresponding header file.
There are many other standard C header files which will be discussed
later.
Define statements are used as follows:
These statements cause the preprocessor to replace all occurences with
the NAME in the #define statement with the replacement string.
PI can now be used as a constant macro (very similar to a variable)
throughout all code that follows the #define statement.
Three types of variables exist:
stdio.h is the header file which must be included for all programs which
are going to have either input from a file or keyboard or output to a
file or monitor.
Stdio.h![]()
Define statements are also a form of preprocessor directive.
DEFINES![]()
#define NAME1 REPLACEMENT1
e.g. #define PI 3.14159
#define NAME1 REPLACEMENT1
...
It is considered good practice to use all uppercase letters in the
names of constant macros. C is case-sensitive.
MAIN FUNCTION![]()
main (void)
A semicolon (;) must follow every statement in the body of a
function.
This tells the compiler that the statement is finshed, allowing it to
move to the next statement.
C NUMBERS
An integer number:
INTEGER NUMBER![]()
(4/3=1, 17/5=3, etc.)
A floating number:
FLOATING NUMBER![]()
(eg 123.4)
(eg 1.234e+002)
C variables are quantities that are given names & whose values can vary
during program execution.
C VARIABLES![]()
(store a single letter or character)
C VARIABLE RULES
(int, double, char, etc)
