C Reference Program 1
Description
A C program to demonstrate the uses of:
Variables (static, external): Integers, Floating point numbers, Characters, Arrays, Character Arrays (strings). Enumerators, printf(); function, Mathematical operations, type casting.
Analysis
In order to demonstrate the uses and applications of each of these a program, which uses each, should be produced providing output for the user to see.
Design
Without using functions/procedures other than main ();
Initially demonstrate the use of printf(); with 'Hello World'.
Initialise each variable type (so far) with a value and use printf(); to display these values.
Comment each printf(); to show readers what it is used for.
Demonstrate a simple use of Enumerators.
Extensively comment on the code to explain what is happening and when.
Implementation
You are welcome to download this program's code should you wish to run it.
Code
Syntax highlighting thanks to pastie.org
C/C++ Program 1
Example Output:
Thanks to Shirley Williams for spotting my initial mistake of not casting a conversion correctly.
A C program to demonstrate the uses of:
Variables (static, external): Integers, Floating point numbers, Characters, Arrays, Character Arrays (strings). Enumerators, printf(); function, Mathematical operations, type casting.
Analysis
In order to demonstrate the uses and applications of each of these a program, which uses each, should be produced providing output for the user to see.
Design
Without using functions/procedures other than main ();
Initially demonstrate the use of printf(); with 'Hello World'.
Initialise each variable type (so far) with a value and use printf(); to display these values.
Comment each printf(); to show readers what it is used for.
Demonstrate a simple use of Enumerators.
Extensively comment on the code to explain what is happening and when.
Implementation
You are welcome to download this program's code should you wish to run it.
Code
Syntax highlighting thanks to pastie.org
C/C++ Program 1
Example Output: