Learnings of the Week [ September 1-5, 2008 ]
In this week, I learned about The C Programming Environment, Data Types,
The Four Parts of C Environment are:
Main menu
Editor status line and edit window
Compiler message window
“Hot Keys” quick reference line
MAIN MENU
The Main Menu instructs C to do something as indicated in the list of menu. It can be activated or can be used by pressing Alt key and the first letter of the menu. For example, press Alt+F to activate File menu.
BASIC MENU OF C
File – used to load and save files, handles directories, invokes DOS and exits C.
Run – used to compile (checks for errors), links and runs the program currently loaded in the environment.
Compile – used to compile the program currently in the environment.
SUBMENU UNDER FILE MENU
Load – enables the user to select a file to be opened or loaded into the editor.
Pick – enables the user to select a file based on the last nine files previously opened or edited.
New – lets the user edit a new file or start new programs.
Save – store or saves the file currently in the editor.
Write to – enables the user to save a file using a different filename.
Directory – displays the content of the current working directory.
Change dir – enables the user to specify the defined path to change the default path or directory.
OS shell – loads the DOS command processor and lets the user execute DOS commands.
Quit – lets the user to exit or quit C.
EDITOR STATUS LINE AND EDIT WINDOW
This is where you type your program and where you see the current line and column of the text you typed. If you try to press Alt- I or Insert Key, the word insert disappears, meaning that the window is in overwrite mode. Press again “insert” to return to the normal mode and notice that the word insert appears again.
MESSAGE WINDOW
The message window is located beneath the middle of edit window and Hotkeys. It is used to display various compiler or linker messages.
HOT KEYS
Hot Keys is located at the bottom of C operating screen. It refers to shortcut or shorthand for selecting a menu. Two sets of Hot keys are available: the normal ones and the alternate set. Press the indicated key to use normal hotkeys. For example, press F1 to activate help. On the other hand, press Alt key briefly and the corresponding Function key to use alternate hot keys.
DATA TYPES
DATA TYPES AND KEYWORDS
There are Five Elementary Data Types in c:
Character (char)
Integer (int)
Floating Point
Double Floating Point
Void
CHAR
Values of type char are used to hold ASCII characters or any 8-bit quantity.
INT
Variables of type int are used to hold real numbers. Real numbers have both an integer.
FLOAT AND DOUBLE
Values of type float and double are used to hold real numbers. Real numbers have both an integer and fractional component.
VOID
The type void has three uses; to declare explicitly a function as returning no value, to declare explicitly a function as having no parameters, and, to create generic pointers.
| Type | Bidwidth | Range |
| Char | 8 | 0 to 255 |
| Int | 16 | -32768 to 32767 |
| Float | 32 | 3.4 X 10-38 to 3.4 X 1038 |
| Double | 64 | 1.7 X 10-308 to 1.7 X 10308 |
| Void | 0 | valueless |
TYPE MODIFIERS
Except type void, the basic data types may have various modifiers preceding them. A modifier is used to alter the meaning of the base type to fit the needs of various situations more precisely. The list of modifiers include the signed, unsigned, long, and short.
KEYWORDS
Keywords in C are reserved words that have a special meaning. Reserved words are words “reserved” by the programming language for expressing various statements and constructs, thus, these may not be redefined by the programmer.
This is the list of 32 Keywords / Reserved words as defined by the ANSI standard.
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
VARIABLES, CONSTANTS, OPERATORS ANS EXPRESSION
IDENTIFIERS DEFINED
Identifiers are composed of a sequence of letters. Digits, and the special character _ (underscore). Avoid using names that are too short or too long. Limit the identifiers from 8 to 15 characters only.
VARIABLES DEFINED
Variables are identifiers that can store a changeable value. These can be different data types.
RULES FOR DEFINING OR NAMING IDENTIFIERS
It must consist only of letters, digits, and underscore.
It should not begin with a digit.
An identifier defined in the C standard library should not be redefined.
It is case sensitive; meaning uppercase is not equal to the lowercase.
Do not include embedded blanks.
Do not use any of the C language keywords as your variable/ identifier.
Do not call your variable / identifier by the same name as other functions.
VARIABLE DECLARATION
All variables must be declared before they may be used. The general form of declaration is int i,j, k; and short i,j,k;. Before declaring variables, specify first the data type of the variable/s. Variables must be separated by comma. All declarations must be terminated by a semicolon (;).
TWO KINDS OF VARIABLES
Local Variables
Variables that are declared inside a function are called local variables. It can only be referenced by statements that are inside the block in which the variables are declared.
Global Variables
Global variables are known throughout the entire program and may be used by any piece of code. Global variables are created by declaring them outside of any function.
CONSTANTS DEFINED
Constants are identifier / variables that can store a value that cannot be changed during program execution.
ARITHMETIC, LOGICAL, RELATIONAL, AND BITWISE OPERATIONS
Operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. There are three classes of operators in C: arithmetic, logical and relational, and bitwise.
ARITHMETIC OPERATORS
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus Divisor
-- Decrement a value
++ Increment a value
RELATIONAL OPERATOR
In the term relational operator, the word relational refers to the relationship values can have with one another.
The relational operators are:
> Greater than
>= Greater than or equal to
< Less than
<= Less than or equal to
== equal
!= Not equal
LOGICAL OPERATOR
In the term logical operator, the word logical refers to the ways these relationships can be connected together using the rules of formal logic.
The logical operators are:
&& AND
|| OR
! NOT
BITWISE OPERATOR
Bitwise operators are the testing, setting or shifting of the actual bits in a byte or a word, which corresponds to C’s standard char and int data types and variants. Bitwise operators cannot by used on type float, double, long double, void or other more complex types.
THE ? OPERATOR
? Operator is a very powerful and convenient operator that can be used to replace certain statements of the if-then-else form.
EVALUATION OF EXPRESSION
Expression refers to anything that evaluates to a numeric value.
ORDER OF PRECEDENCE
()
!, unary +, -
*. /. %
binary + , -
<, <=, >, >=
==, !=
&&
||
Posted by:
RAE ANGELINE S. PALEN
IV - RIZAL


0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home