You are on page 1of 12

Introduction

doandongnguyen@gmail.com
Course information

• Programming 1 – INS2020
• Theory + Exercises
• Mid-term quiz (30%) + Final exam (60%)
• Books:
• The C Programming language (2nd), Brian W. Kerninghan & Dennis M. Ritchie,
Prentice-Hall, 1998
• The C++ Programming Language (3rd), Rjarne Stroustrup, Addison-Wesley, 1997
• IDE:
• MS Visual Studio (Community, Professional) for Windows/Mac Users
• Notepad++ (requires a separate compiler) for Windows Users
• Vim + GCC compiler for GNU/Linux
Contents

• Introductions: Programming, algorithms, Operating Systems (OS), ..


• Basics of C Programming: Variables, Data types, ..
• Arrays and Strings
• Functions and Pointers
• Data Structures: Complex data types
• File Processing: Text files, binary files, ..
What is programming?

• Instruction set: Basic operations of a computer


• A computer program: a collection of the instructions of a particular
computer
• Algorithm: a method to solve a problem
What is programming?

• Example: Tests if a number is odd/even


• Algorithm for solving the problem:
• Divide the number by two
• If the remainder of the division is Zero -> even
• Otherwise, the number is odd
• Implement the algorithm in term of instructions (Express in a particular
programming language C/C++, VB.NET, ..)
• Compile into machine language
Programming Language

• Low-level languages
• Machine dependent (machine language: Binary number)
• Assembly
• Need an assembler to translate into machine instructions
• High-level languages
• A program can be written in a language to be machine independent (requires a
compiler)
• Ex: Fortran (FORmula TRANslation), C/C++, ..
Operating Systems (OS)

• OS: a program to control/mange operations of a computer.


• Programs/Software installed on the OS.
• Examples:
• GNU/Linux Dist.: Ubuntu, Arch Linux, Red Hat, ..
• Microsoft Windows : Windows 7, Windows 8, Windows 10, ..
• MacOS
Compiling Programs

• Compiler: to analyze a program


and translate it into a form that
is suitable for execution
• Suffix of object code: .obj
(Windows), .o (Linux, Unix)
• Process of compiling and linking
called building
• Each of the statements of the
program will be executed
sequentially
C Programming Language

• Was pioneered by Dennis


Ritchie at AT&T Bell Lab in
1970s
• In 1990, the first official ANSI
standard definition of C was
published
• In 1999, ANSI C99 was
published
• C is a general-purpose
structured, high-level
programming language
C Programming Language

• Lowercase and uppercase letters are distinct


• A statement must be end with a semicolon “;”
• {..} is a block statement
• Reserved words or names cannot be used for variable names:
• Int, float, if, for, ..

• Comments in C:
• /*…*/
• //
• .. Details will be in next lessons
Example

/***helloworld.c***/ OUTPUT
Hello World
#include <stdio.h>

int main(void){
printf(“Hello World”);
return 0;
}
Exercises

• Install MS Visual Studio (community)


• Run sample codes

You might also like