Introduction to Computer Science by Huong Nguyen - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

index-1_1.jpg

Introduction to Computer Science

By: Huong Nguyen

Online: < http://cnx.org/content/col10776/1.1> This selection and arrangement of content as a collection is copyrighted by Huong Nguyen.

It is licensed under the Creative Commons Attribution License: http://creativecommons.org/licenses/by/3.0/

Collection structure revised: 2009/07/29

For copyright and attribution information for the modules contained in this collection, see the " Attributions" section at the end of the collection.

Introduction to Computer Science

Table of Contents

Chapter 1. Introduction to Computer Science

1.1. Basic concepts

Information & Information Processing

Data – Information – Knowledge

Information Processing

History of Computers

The First Generation - 1940-1956

The Second Generation - 1956-1963

The Third Generation - 1964-1971: Integrated Circuits

The Fourth Generation - 1971-Present: Microprocessors

The Fifth Generation - Present and Beyond: Artificial Intelligence

Classification of Computers

Computer Science and Relevant Sciences

Computer Science

Information Technology

Information and Communication Technology

1.2. Data Representation in a Computer

Number Representation in Various Numeral Systems

Base - b numeral system

Binary System

Hexadecimal System

Octal System

Converting from decimal to base–b

Data Representation in a Computer. Units of Information

Basic Principles

Units of Information

Unsigned Integers

Signed Integers

Arithmetic Operations on Integers

Addition and Subtraction of integers

Multiplication and Division of Integers

Logical operations on Binary Numbers

Symbol Representation

Basic Principles

Unicode Code Table

Representation of Real Numbers

Basic Principles

IEEE 754/85 Standard

1.3. Computer Systems

Computer Organization

General Model of a Computer

The Central Processing Unit (CPU)

Memory

Input-Output Devices

Buses

Computer Software

Data and Algorithms

Programs and Programming Languages

Classification of Computer Software

1.4. Operating Systems

Basic concepts

File

File Management

Some Common Operating Systems

MS-DOS

Microsoft Windows

The Most Common Commands of an Operating Systems

Microsoft Windows

Brief History of Microsoft Windows

How to start and exit from Windows XP

Starting Windows XP

Shutting down Windows XP

Basic Terms and Operations

Using a computer mouse

The Control Panel

Configuring the Screen

The screensaver

Configuring the Mouse

Adding or removing Programs

Changing the Regional and Language Options

Add a printer

Delete a printer

The Windows Explorer

Starting the Explorer

The Explorer’s window

Opening Files

Selecting Files

Creating and Deleting Folders

Deleting folders

Copying Files or Folders

Moving Files or Folders

Changing the name of a File or Folder

Files and Folders Properties

Run a program on Windows

The Command Prompt

The Recycle Bin

1.5. Computer Networks

History of Computer Networks

Classification of Computer Networks

Classification by scale

Classification by functional relationship

Major Components of a Computer Network

Network Topology

Point to point

Bus

Ring

The Internet

History of the Internet

Internet Services

Advantages of the Internet

How to Connect to the Internet?

Chapter 2. The C programming languages

2.1. Introduction to C

History of the C Programming Language

The Integrated Development Environment of C++ 3.0

Basic Components of C Programs

Symbols

Key Words

Identifiers

Data Types

Constants

Variables

Operators

Expressions

Functions

Statements

Comments

C program structure

2.2. Data Types and Expressions

Standard Data Types

Declaration and Usage of Variables and Constants

Functions printf, scanf

Other Input and Output Functions

Expressions

Operators

Arithmetic Operators

Assignment Operators

Logical and Relational Operators

Bitwise Operators

Increment and Decrement Operators

Memory Addressing Operators

Type Conversions

Precedence of Operators

2.3. The Control Flow

Statements and Blocks

If, If else statements

The Switch Statement

Loops : While and Do While, For

The while statement

The do statement

The for statement

Loop Flow Control

The break statement

The continue statement

Goto and Labels

2.4. Pointers and Arrays

Pointers and Addresses

Pointers

Pointer declaration

& and * operators

Pointer Assignment

Initializing Pointers

Operators on Pointers

Pointer to pointer

NULL Pointers

void Pointers

Arrays

Basic of Arrays

Declarations and Usage of Arrays

Multidimensional Arrays

Accessing Array Elements

Initializing Arrays

Operations on arrays

Read the elements of a 1-dimensional array:

Printing array elements

Find the maximum value stored in the array.

Searching

Sorting

Pointers vs Arrays

Array Pointers

Pointer Arrays

2.5. Functions

Basic of C functions

Declaration and Usage of Function

Function Declarations

Usage of Functions

Scope of Variables

Local block

Functions and Storage Class Specifiers

Function prototype

Parameters passing

Arrays as Function Parameters

Pointers as Function Parameters

2.6. Strings

Basic of strings

Declarations and Uses of Strings

Built-in Functions for Character and String Processing

Character Processing Functions

Character Classification Functions

Case Mapping Functions

String Processing Functions

2.7. Structures

Introduction

Declarations and Usage of Structures

Creating Structures as New Data Types

Creating variable of a struct type

Referencing Structure Members with the Dot Operator

Initializing Structure Variables

Copying Structure Variables

Comparing Values of Structures

Arrays of Structures

Operations on Structures

Passing Structures to and from Functions

The Arrow Operator

Passing Structures by Reference

Enumerated Types

2.8. Files

Basics and Classification of Files

Operations on Files

Declarations

Open Files

Access to Text Files

Write data to text files

Read data from text files

feof() function

fflush() function

fgetc() function

Other function:

fseek() function

rewind() function

EOF and errors

Access to Binary Files

Write data to binary files

Read data from binary files

Close Files

Index

Chapter 1. Introduction to Computer Science

1.1. Basic concepts*

Information & Information Processing

Data – Information – Knowledge

The content of the human mind can be classified into four categories:

Data: symbols;

Information: data that are processed to be useful; provides answers to "who", "what", "where", and "when" questions;

Knowledge: understanding of data and information; answers "how" questions;

Wisdom: evaluated understanding.

Data

Data consist of raw facts and figures - it does not have any meaning until it is processed and

turned into something useful.

Data comes in many forms; the main ones are letters, numbers and symbols.

Data is a prerequisite to information. For example, the two data items below could represent some

very important information:

DATA INFORMATION

123424331911 Your winning Lottery ticket number

211192 Your Birthday

An organization sometimes has to decide on the nature and volume of data that is required for

creating the necessary information.

Information

Information is the data that has been processed in such a way as to be meaningful to the person

index-10_1.jpg

who receives it.

INFORMATION = DATA + CONTEXT + MEANING

Example

Consider the number19051890. It has no meaning or context. It is an instance of data.

If a context is given : it is a date (Vietnamese use French format ddmmyyyy). This allows us to

register it as 19th May 1890. It still has no meaning and is therefore not information

Meaning : The birth date of Vietnamese President Ho Chi Minh.

This gives us all the elements required for it to be called 'information'

Knowledge

By knowledge we mean the human understanding of a subject matter that has been acquired

through proper study and experience.

Knowledge is usually based on learning, thinking, and proper understanding of the problem area.

It can be considered as the integration of human perceptive processes that helps them to draw

meaningful conclusions.

Consider this scenario: A person puts his finger into very hot water.

Data gathered: The finger nerve sends pain data to the brain.

Processing: The brain considers the data and comes up with...

Information: The painful finger means it is not in a good place.

Action: The brain tells finger to remove itself from hot water.

Knowledge: Sticking the finger in hot water is a bad idea.

Knowledge is having an understanding of the "rules".

The terms Data, Information, Knowledge, and Wisdom are sometimes presented in a form that

suggests a scale.

index-11_1.jpg

Figure 1.1.

Data, Information, knowledge, wisdom along a scale

Information Processing

Information processing is the change (processing) of information in any manner detectable by an

observer. Information processing may more specifically be defined in terms by Claude E. Shannon

as the conversion of latent information into manifest.Input, process, output is a typical model for

information processing. Each stage possibly requires data storage.

Figure 1.2.

Model of information processing

Now that computer systems have become so powerful, some have been designed to make use of

information in a knowledgeable way. The following definition is of information processing

The electronic capture, collection, storage, manipulation, transmission, retrieval, and presentation of information in the form of data, text, voice, or image and includes telecommunications and

office automation functions.

History and Classification of Computers

History of Computers

Webster's Dictionary defines "computer" as any programmable electronic device that can store, retrieve, and process data.

Blaise Pascal invents the first commercial calculator, a hand powered adding machine

In 1946, ENIAC, based on John Von Neuman model completes.The first commercially successful

computer is IBM 701.

A generation refers to the state of improvement in the development of a product. This term is also

used in the different advancements of computer technology. With each generation, the circuitry

has gotten smaller and more advanced than the previous generations before it. As a result of the

miniaturization, the speed, power and memory of computers has proportionally increased. New

discoveries are constantly being developed that affect the way we live, work and play. In terms of

technological developments over time, computers have been broadly classed into five generations.

The First Generation - 1940-1956

The first computers used vacuum tubes for circuitry and magnetic drums for memory, and were

often enormous, taking up entire rooms. They were very expensive to operate and in addition to

using a great deal of electricity, they generated a lot of heat, which was often the cause of

malfunctions. First generation computers relied on machine language to perform operations, and

they could only solve one problem at a time. Input was based on punched cards and paper tape,

and output was displayed on printouts.

The computers UNIVAC , ENIAC of the US and BESEM of the former Soviet Union are examples

of first-generation computing devices.

The Second Generation - 1956-1963

Transistors replaced vacuum tubes and ushered in the second generation of computers. Computers

becomed smaller, faster, cheaper, more energy-efficient and more reliable than their first-

generation predecessors. Second-generation computers still relied on punched cards for input and

printouts for output. High-level programming languages were being developed, such as early

versions of COBOL and FORTRAN.

The first computers of this generation were developed for the atomic energy industry.

The computers IBM-1070 of the US and MINSK of the former Soviet Union belonged to the

second generation.

The Third Generation - 1964-1971: Integrated Circuits

The development of the integrated circuit was the hallmark of the third generation of computers.

Transistors were miniaturized and placed on silicon chips, called semiconductors, which

drastically increased the speed and efficiency of computers. Users interacted with third generation

computers through keyboards and monitors and interfaced with an operating system, which

allowed the device to run many different applications at one time. Typical computers of the third

generation are IBM 360 (United States) and EC (former Soviet Union).

The Fourth Generation - 1971-Present: Microprocessors

The microprocessor brought the fourth generation of computers, as thousands of integrated

circuits were built onto a single silicon chip. What in the first generation filled an entire room

could now fit in the palm of the hand. The Intel 4004 chip, developed in 1971, located all the

components of the computer - from the central processing unit and memory to input/output

controls - on a single chip.

In 1981 IBM introduced its first computer for the home user, and in 1984 Apple introduced the

Macintosh. Microprocessors also moved out of the realm of desktop computers and into many

areas of life as more and more everyday products began to use microprocessors.

As these small computers became more powerful, they could be linked together to form networks,

which eventually led to the development of the Internet. Fourth generation computers also saw the

development of GUI (Graphic User Interface), the mouse and handheld devices.

The Fifth Generation - Present and Beyond: Artificial Intelligence

Fifth generation computing devices, based on artificial intelligence, are still in development,

though there are some applications, such as voice recognition, that are being used today. The use

of parallel processing and superconductors is helping to make artificial intelligence a reality.

Quantum computation and molecular and nanotechnology will radically change the face of

computers in years to come. The goal of fifth-generation computing is to develop devices that

respond to natural language input and are capable of learning and self-organization.

Classification of Computers

Computers are available in different shapes, sizes and weights, due to these different shapes and

sizes they perform different sorts of jobs from one another.

Mainframe and Super Computers

The biggest in size, the most expensive in price than any other is classified and known as super

computer. It can process trillions of instructions in seconds. Governments specially use this type

of computer for their different calculations and heavy jobs. This kind of computer is also helpful

for forecasting weather reports worldwide.

Another giant in computers after the super computer is Mainframe, which can also process

millions of instruction per second and capable of accessing billions of data. This computer is

commonly used in big hospitals, airline reservations companies, and many other huge companies

prefer mainframe because o