introduction to computer and programing

29
ion to Computer and Programin g Thanachat Thanomkulabut

Upload: monita

Post on 07-Feb-2016

83 views

Category:

Documents


1 download

DESCRIPTION

Introduction to Computer and Programing. Thanachat Thanomkulabut. Outline. Introduction to computer Programming Languages C# Language Overview. Introduction to computer. Definition of Computer. Devices for performing computations at high speeds with great accuracy - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Introduction to Computer and Programing

Introduction to Computer and ProgramingThanachat Thanomkulabut

Page 2: Introduction to Computer and Programing

Outline2

Introduction to computer Programming Languages C# Language Overview

Page 3: Introduction to Computer and Programing

Definition of Computer3

Devices for performing computations at high speeds with great accuracy

A machine that can be programmed to manipulate symbols.

A machine that can quickly store and retrieve large amounts of data.

Physical components are known as “Hardware”

Introduction to computer

Page 4: Introduction to Computer and Programing

Computer Categories4

• Desktop Computer• Laptop, Notebook, Netbook• PDA – Personal Digital Assistant

Personal Computer

•High Computation PowerSupercomputer and Mainframe

Introduction to computer

Page 5: Introduction to Computer and Programing

Computer Systems Hardware

Actual physical machines (equipment) that make up the computer

5

Software Programs written

for a specific application are often called softwares

Introduction to computer

Page 6: Introduction to Computer and Programing

Computer Components

CPU (Central Processing Unit)

Primary storage (memory)

Secondary storage (disks, tapes, etc.) Input devices (mouse, keyboard, etc.) Output devices (screen, printer, etc.)

6

Introduction to computer

Page 7: Introduction to Computer and Programing

Hardware - Process

INPUT

Processing

Primary storage

OUTPUTcommand

Information

result

Secondary

storage

Introduction to computer

Page 8: Introduction to Computer and Programing

Computer Storage

RAM ROM

8

Introduction to computer

Primary Storage

Secondary StorageRead OnlyNon - Volatile

Can Read/Write

Volatile

Much FasterMore

expensive

SlowerLess

expensive

Computer Storage

Page 9: Introduction to Computer and Programing

Data Representation9

Data in computer is represented in “bit” bit = binary digit

0 or 1 Byte = 8 bits 1 byte can represent many kinds of data

1 byte = 01100001 the above 1 byte represents character “a” or

97 the meaning of 1 byte depends on the

program1 Kbyte = 210 = 1024 bytes1 Mbyte = 220 = 1,048,576 bytes1 Gbyte = 230 = 1,073,741,824 bytes1 Tbyte = 240 = 1,099,511,627,776 bytes

Introduction to computer

Page 10: Introduction to Computer and Programing

ASCII Table10

Page 11: Introduction to Computer and Programing

Outline11

Introduction to computer Programming Languages C# Language Overview

Page 12: Introduction to Computer and Programing

Programming Languages12

Program A set of instructions for a computer to

follow, written in specific programming language

Types of programming language High-Level Language Assembly Language Machine Language

Programming Languages

Page 13: Introduction to Computer and Programing

Programming LanguagesHigh-level VS Assembly VS Machine Language

13

High-level Language Nearly like human word

SUM := A * 2 + ALPHA/3; Assembly Language

Some key words are understandable MULL3 A, #2, RADDL3 R6, R7, SUM

Machine Language Only “0” and “1”

0001100001100011001111 10011000111

Computer itself understands only Machine language

Page 14: Introduction to Computer and Programing

Language translator14

Hello World!

_

High-level language•static void Main( )

{ Console.WriteLine("Hello

World!");}

Interpreter/ Compiler Assembly language

•pushl %ebpmovl %esp, %ebpsubl $8, %espandl $-16, %esp

Machine language• 00011000110001110

0011000111010111100011000110001110

Assembler

Machine

Programming Languages

Page 15: Introduction to Computer and Programing

High-Level Languages Procedural

Language Fortran Cobol Basic C Pascal

Object-Oriented Language C++ Java C#C#

Functional Language Lisp

Logic Language Prolog

15

Programming Languages

Page 16: Introduction to Computer and Programing

Outline16

Introduction to computer Programming Languages C# Language Overview

Page 17: Introduction to Computer and Programing

A simple C# Program17

Grouping using { }

C# Language Overview

Page 18: Introduction to Computer and Programing

A simple C# Program18

A statement must be ended with semicolon “;”

C# Language Overview

Page 19: Introduction to Computer and Programing

A simple C# Program19

C# syntax is case-sensitive

namespace NAMEspace

Main() main()

C# Language Overview

Page 20: Introduction to Computer and Programing

A simple C# Program20

White space means nothing

static void Main(string[] args) { Console.WriteLine("Hello World!");}

static void Main(string[] args){Console.WriteLine("Hello World!");}

C# Language Overview

Page 21: Introduction to Computer and Programing

A simple C# Program21

Anything between /* */ or after // is considered a comment

Comments will not be translated

C# Language Overview

Page 22: Introduction to Computer and Programing

Program Structure The starting point of the program is:

This is known as the method Main A method is put inside a class A class may be put inside a namespace

static void Main () { ... starting point ... }

22

C# Language Overview

Page 23: Introduction to Computer and Programing

Program Structure In C#

A program can contain several namespaces A namespace can contain several classes A class can contain several methods

In other words Think of a namespace as a container of classes Think of a class as a container of methods

method1method1method2method2

namespacenamespaceClassClass

ClassClass

23

C# Language Overview

Page 24: Introduction to Computer and Programing

Program Structure

For this 204111 course Program with only one class and at most one

namespace For now until sometime before midterm

Program with one method (i.e., Main)

namespace HelloW { class HelloWClass { static void Main () { System.Console.WriteLine("Hello World!"); System.Console.ReadLine(); } }}

24

C# Language Overview

Page 25: Introduction to Computer and Programing

Naming C# allows user to give a name to

something. A user-defined name can be any word

with some rules. Remember!!! C# is a case-sensitive

language.

* Case Sensitive Example

KU ≠ kU ≠KU ≠ kU ≠ kuku

C# Language Overview

25

Page 26: Introduction to Computer and Programing

Naming Rules Letters, digits and underscores(_) First character must be a letter or _ Up to 63 characters long Must not be a reserved word

C# Language Overview

26

Example

name Name

_data

9point

class class_A class_"A"

point9

Page 27: Introduction to Computer and Programing

C# Reserved WordsC# Language Overview

27

Page 28: Introduction to Computer and Programing

More Resources How Bits and Bytes Work

(http://www.howstuffworks.com/bytes.htm) Byte (http://en.wikipedia.org/wiki/Byte) Computer hardware

(http://en.wikipedia.org/wiki/Computer_hardware) Software (http://en.wikipedia.org/wiki/Software) Programming language

(http://en.wikipedia.org/wiki/Programming_language)

List of programming languages (http://en.wikipedia.org/wiki/List_of_programming_languages)

28

Page 29: Introduction to Computer and Programing

Any question?