85
Enter the following program:
.
M A I N ( ) Shift {
.
.
SPC
.
P R I N T F ( “ CAPS H CAPS O W SPC A R E SPC
.
Y
.
.
O
.
.
U
.
Shift
.
?
.
Shift ¥ N ”
.
)
.
.
;
.
.
.
SPC
.
P R I N T F ( “ CAPS F CAPS I N E , T H A N
.
.
K
.
SPC
.
Y
.
.
O
.
.
U
.
Shift ¥ N ”
.
)
.
.
;
.
.
.
Shift }
.
.
printf(“How are you?¥n”);
↵
printf(“Fine,thank you¥n”);
↵
}
↵
< 4>
The following shows how the program is stored in the source file:
main()
{
printf(“How are you?¥n”);
printf(“Fine,thank you¥n”);
}
As already stated, C programs instructions are written using lower case characters.
Also note the following characters in lines 1 and 4 of the program:
main() {
………
}
These are called the
function
that makes up the C program. The word “main”
defines the function name, and the statements between the braces are actually
executed. Actually, you can assign your function any name you wish, but “main” is
special in that the computer will always begin execution from the function named
“main”.
Lines 2 and 3 contain two printf() statements. The printf() statement is actually a
function of C language that is used to output characters to the display. Such
functions are called
standard functions
. The character strings included within the
parenthesis following printf are what is output to the display. Note that a
character
string
is defined as such by being included within double quotation marks. A
character string or anything else that is included within the parentheses is called an
argument
.
The “¥n” at the end of each printf() character string is called a
newline
character, and
advances the output to the left margin of the next line. Here the newline character is
at the end of the string, but you can also include it within the string to tell the
computer to go to the beginning of the next line.
Note that the newline character is noted “\n” in the ANSI C language. Nevertheless,
the backslash character (Ascii code 92) is not available on the pocket computer. The
character coded 92 is the Yen character (see chapter 1.6). Hence, every time a
backslash would be required in ANSI C, we will use the Yen character instead.