
Chapter 1: C Basics
1
Lecturer: PhD. DO Thi Ngoc Diep
SCHOOL OF ELECTRICAL AND ELECTRONIC ENGINEERING
HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

2
C programming language
•C is a language for procedural programming.
•Usually goes with top-down analysis: Divide a large program (function) into
smaller functions.
•Function is a series of statements that are grouped together and
given a name
•A statement is a command to be executed when the program runs
•Each function has
•Input, output data (variables)
•Structured instruction set: sequential, decision, loop
•A C program may consist of many function, but only one main()
function is mandatory.
•main() is called automatically when the program is executed

3
Some notes
•Character set: a-z, A-Z, 0-9, symbols… (ASCII)
•The syntax is case sensitive: int, Int, INT are completely different
•Symbol ; used to separate single statements
•Symbol { } used to specify a block of statements
•Comments: ignored while compiling
•Symbol //, /* */ marks the beginning and the end of a comment
•Keywords: reserved meaning in a language
•Identifier: name for variables, functions, macros, other entities etc.
•It can contain letters, digits, underscores, but must begin with a
letter or a underscore.
•Length: 1-31 characters (may be changed)
•Can not be keywords

4
http://btechsmartclass.com

5
The first C program
/* hello.c */
#include <stdio.h>
int main() {
printf("Xin chao!\n");
return 0;
}
Program:
1. Ask the computer to print a line of text to the screen
2. Returns 0 to the calling program
main() function
starting point !
Comment
Directives (without “;” ,
compilation guide)
#include library
#define
Set of statements
Return statement

