Getting Started Flashcards
Four Important aspects of any language:
- Way it stores data
- Way it operates upon it.
- how it accomplishes input and output.
- how it lets you control the sequence of execution of instructions in a program.
Why is C used in some parts of Operating systems?
Speed of execution.
Device drivers are written in C.
Steps of learning C:
- Alphabets; Digits; Special Symbols.
- Constants; Variables; Keywords
- Instructions
- Program
The C character Set
All alphabets, Capital and small.
All digits 0-9
Special Symbols o keyboard [31].
[ ~ is but ` is not valid]
Constant, Variable and Keywords:
These formed by the combination of the C character set.
Constants: Entity with a fixed value.
Variables; Entity with changing values.
Variable names theory:
The memory locations are given names and since the value stored in these memory keeps changing hence called variable names.
This allows us to retrieve and use the value stored in the memory location.
Types of C constant:
- Primary
Integer constant; Real Constant; Character Const. - Secondary constants
Array; Structure; Pointer; Union; Enum,..etc
Rules Of Integer Constant:
- Must have at least 1 digit.
- Must not have a decimal point.
- Can be +ve or -ve.
- No sign implies +ve.
- No commas and blanks allowed.
- Range: -32768 to 32767 [ depends on Compiler, this
is for a 16-bit compiler.]
Rules for constructing Real Constants:
aka Floating Point Constants. expressed in 2 forms: 1. Fractional Form: a. at least 1 digit. b. Decimal point Must. c. Can be +ve or -ve, default +ve d. No commas, blanks allowed.
- Exponential Form: [For too small or too big value]
a. Has mantissa and exponent[separated by e]
b. Mantissa can be +ve or -ve, Default +ve.
c. Exponent must have at least 1 digit again maybe +ve or -ve. Dafault is +ve.
d. Range: -3.4e38 to 3.4e38
Rules for Constructing Character Constants:
Character constant has max length of 1 character.
Enclosed in inverted commas, both single inverted, towards left.
like : ‘A’
‘1’
‘@’
In a language, the type of variables supported depends on ?
the type of constant supported.
Rules for constructing Variable Names:
- length 31 (some compilers: 247)
- First char must be alphabet or underscore
- No commas or blanks are allowed.
- ONly special symbol allowed is an underscore.
These rules apply for all types of primary and secondary variables.
To differentiate between variables what is done?
Type declaration statements.
int varname;
float varname;
char varname;
C keywords:
keywords cant be used as var names.
they are already explained to the compiler.
AKA reserved words
There are 32.
auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof volatile do if static while
Compiler Specific keywords:
ANSI said they should be preceded by 2 underscores.
like __near, __far, __asm
C program
how do instructions or statements make them?
Each instruction is written as a separate statement.
Therefore, a C program compromises of a series of statements.
They must appear in the order in which we expect them to execute.
To increase readability u can insert blacnk spaces btw words but not btw varnames, constant, keyword.
Statements are entered in small case letters.