Chapter 01
Chapter 01
language Algol-60
1950
Fortran 1963
CPL
1960 Algol-60 Cobol 1967
CPL BCPL
Simula BCPL
1970
1970 Pascal B
B
Smalltalk
C 1972
1980 Ada C
C++ 1985
ANSI C
1990 C++1
Java
Overview of C Language
1
ü Small size
ü C is modular
ü Loose typing
ü Structured language
ü Low level programming readily available
ü C has a very powerful set of operators
ü Rich data structure
ü C efficient on most machines
2
The Program Framework of C Language
The Program Framework of C Language
What should I do if there is an error in the
program?
Overview of C Language
1C Program Structure
Characters Operands +
operators
6
1 Essential Elements
Numeral: 0 1 2 … 9
Letter: ABC…Z a b c…z
Character
Operator: + - = > < …
Others: \r \n \t …
Expression
branch: if-else; switch
Statement Control loop: for; while
Jump: break; goto…
Compound
8
1 “Hello, world.” Program
/* File: hello.c
This program prints
program comment
the message “Hello,
world.” on the screen.
*/
library inclusions
#include <stdio.h>
void main ()
{ main function
printf (“Hello, world.\n”);
}
• The program is stored as a text file named hello.c
• .c identifies the file as a C program.
9
1 Compile it
10
1 Run it
11
1 Run it
12
The C Chapter
Programming
1. A Tutorial
LanguageIntroduction
Chapter
1.1 Getting
1. A Tutorial
Started
Introduction
13
The C Chapter
Programming
1. A Tutorial
LanguageIntroduction
Chapter
1.1 Getting
1. A Tutorial
Started
Introduction
#include <stdio.h>
main( )
{
printf (“hello,”);
printf (“world”);
printf(“\n”);
}
14