PAGEFLOP
FORWARD
SELECTOR
SELAGAIN
WRONGSEL
YOUR SELECTION IS NOT IN THE 0 - #SELIMIT RANGE Please try again
SELRTRN
AANVANG
Copyright CourseWare Technologies Inc., 1985-88
Lesson - 1
INTRODUCTION TO C
MENU
Introduction to C|Topics to Learn|1-0|10,44
# Topic
--- -------
1 - An Overview
2 - Why C?
3 - The C Alphabet
4 - How to Write a Simple C Program
5 - How to Run a C Program
6 - Lesson Review
0 - Return to the Main Menu
P1
Introduction to C|An Overview|1-1.1|13,44
The C programming language is:
* a general purpose language,
* concise,
* middle level, and
* free in its format.
C allows good design techniques like:
* top down design,
* stepwise refinement, and
* structured/modular programming.
P2
Introduction to C|Why C?|1-2.1|9,55
Benefits of C include:
* code and compiler portability,
* efficient object programs,
* easy access to machine level operations,
* easy access to facilities of the UNIX
operating system,
* powerful and straightforward data structures,
* a rich set of operators, and
* a small language size.
P3
Introduction to C|The C Alphabet|1-3.1|9,54
All C identifiers and expressions are made up
of the following characters:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
a b c d e f g h i j k l m n o p q r s t u v w x y z
0 1 2 3 4 5 6 7 8 9
! " # $ % & ' ( ) * + , - . / \
: ; < = > ? @ [ ] _ { } ~
P4
Introduction to C|A Simple C Program|1-4.1|7,50
A program is a group of building blocks
called functions.
A function is a group of one or more C
statements designed to accomplish a specific
task.
P5
Introduction to C|A Simple C Program|1-4.2|9,54
A simple C program follows. Note that comments are
delimited by /* and */ and that \n represents a
new line.
main() /* C Programming Example */
{
printf("This is my first C program\n");
}
P6
Introduction to C|A Simple C Program|1-4.3|16,50
In the previous example:
/* and */ enclose a comment.
main() is a function name that begins a function
block (a program can have only one main).
{ is an opening brace, beginning a function body
or a compound statement.
printf(". . ."); is a function body with statements.
} is a closing brace, denoting the end of function
body or compound statement.
\n denotes the newline character.
P7
Introduction to C|How to Run a C Program|1-5.1|12,54
There are several ways to compile and run a C program.
Assume you have the text of a program in a file called
prog1.c. The command:
cc prog1.c
compiles your program and produces an executable file
called a.out. The command:
a.out
executes or runs the file a.out.
P8
Introduction to C|How to Run a C Program|1-5.2|16,54
mv a.out prog1
The above command renames a.out prog1.
prog1
The above command runs prog1.
cc -o prog1 prog1.c
the -o option in the command line above indicates
that an output file name follows (in this case, prog1).
This saves you the trouble of moving a.out to a new
file name.
P9
Introduction to C|How to Run a C Program|1-5.3|3,54
cc -c prog1.c
The -c option produces an object file called prog1.o
only; it does not produce an executable image.
REV1