Chapter3 Fundamental InputOutput
Chapter3 Fundamental InputOutput
Fundamental of C Programming
Language
and
Basic Input/Output Function
Preprocessor
Preprocessor program
Phase 2 : Disk
processes the
code.
Compiler
Phase 3 : Compiler Disk creates object
code and stores
it on Disk.
Primary
Memory
Phase 6 : C P U (execute) CPU takes each
instruction and
executes it, storing
: new data values as
. the program executes.
#include <stdio.h>
void main(void)
{
printf(“I love programming\n”);
printf(“You will love it too once ”);
printf(“you know the trick\n”);
}
I love programming
You will love it too once you know the trick
return 0;
} } } }
}
Principles of Programming - NI 2005 11
Statement cont…
Statement has two parts :
Declaration
The part of the program that tells the compiler
the names of memory cells in a program
Executable statements
Program lines that are converted to machine
language instructions and executed by the
computer
statement(s);
} End of segment
Enumeration
Values are given as a list
Example: enum Language {
Malay,
English,
Arabic
};
Principles of Programming - NI 2005 21
Constant example – volume of a
cone
#include <stdio.h>
void main(void)
{
const double pi = 3.412;
double height, radius, base, volume;
void main(void)
{
double height, radius, base, volume;
Output operation
an instruction that displays information stored
in memory to the output devices (such as the
monitor screen)