Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Computer and Programing Thanachat Thanomkulabut.

Similar presentations


Presentation on theme: "Introduction to Computer and Programing Thanachat Thanomkulabut."— Presentation transcript:

1

2 Introduction to Computer and Programing Thanachat Thanomkulabut

3 Outline 2  Introduction to computer  Programming Languages  C# Language Overview

4 Definition of Computer 3  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

5 Computer Categories 4 Desktop Computer Laptop, Notebook, Netbook PDA – Personal Digital Assistant Personal Computer High Computation Power Supercomputer and Mainframe Introduction to computer

6 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

7 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

8 Hardware - Process INPUT Processing Primary storage OUTPUT command Information result Secondary storage Introduction to computer

9 Computer Storage RAMROM 8 Introduction to computer Primary Storage Secondary Storage Read Only Non - Volatile Can Read/Write Volatile Much Faster More expensive Slower Less expensive Computer Storage

10 Data Representation 9  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 program 1 Kbyte = 2 10 = 1024 bytes 1 Mbyte = 2 20 = 1,048,576 bytes 1 Gbyte = 2 30 = 1,073,741,824 bytes 1 Tbyte = 2 40 = 1,099,511,627,776 bytes Introduction to computer

11 ASCII Table 10

12 Outline 11  Introduction to computer  Programming Languages  C# Language Overview

13 Programming Languages 12  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

14 High-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 MULL3A, #2, R ADDL3R6, R7, SUM  Machine Language  Only “ 0 ” and “ 1 ” 00011000011 00011001111 10011000111 Computer itself understands only Machine language

15 Language translator 14 Hello World! _ High-level language static void Main( ) { Console.WriteLine("Hello World!"); } Interpreter / Compiler Assembly language pushl %ebp movl %esp, %ebp subl $8, %esp andl $-16, %esp Machine language 00011000110001110 00110001110101111 00011000110001110 Assembler Machine Programming Languages

16 High-Level Languages  Procedural Language  Fortran  Cobol  Basic  C  Pascal  Object-Oriented Language  C++  Java  C#  Functional Language  Lisp  Logic Language  Prolog 15 Programming Languages

17 Outline 16  Introduction to computer  Programming Languages  C# Language Overview

18 A simple C# Program 17 Grouping using { } C# Language Overview

19 A simple C# Program 18 A statement must be ended with semicolon “;” C# Language Overview

20 A simple C# Program 19 C# syntax is case-sensitive namespaceNAMEspace Main()main() C# Language Overview

21 A simple C# Program 20 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

22 A simple C# Program 21 Anything between /* */ or after // is considered a comment Comments will not be translated C# Language Overview

23 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... } static void Main () {... starting point... } 22 C# Language Overview

24 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 method1 method2 namespace Class Class 23 C# Language Overview

25 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(); } namespace HelloW { class HelloWClass { static void Main () { System.Console.WriteLine("Hello World!"); System.Console.ReadLine(); } 24 C# Language Overview

26 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 ≠ kU ≠ ku C# Language Overview 25

27 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 nameName _data 9point class class_Aclass_"A" point9

28 27 Identifier examples  Valid examples  score, count, total  score1, count99, total09  score_1, count_99, total_99  myStudentId  my_student_id  Invalid examples  point&score  total-number  9points

29 28 using System; namespace Sample1 { class Program { static void Main(string[] args) { const double payrate = 120.50; int hrs; double wages; Console.Write ("Please enter working hours : "); hrs = int.Parse(Console.ReadLine()); if (hrs > 40 ) wages = (hrs * payrate) + ((hrs-40)* payrate*2); else wages = hrs * payrate; Console.WriteLine("Employee works " + hrs + " must earn "+wages); } fDeclaration Part : This part is used to declare constant and variable. fProgram body: This part is used to put statements for execution.

30 29 C# Program: class declaration  Class name  Member declarations  Data member  Method (or functions)  In the beginning of the class, we usually use only one method: Main --- which is where our program starts. class MainClass { public static void Main(string[] args) { const double pi = 3.1416; int radius; double area; radius = int.Parse(Console.ReadLine()); area = pi*radius*radius; Console.WriteLine(area); }

31 30 Notes for Identifiers  Identifiers are case-sensitive  mystudentId  Mystudentid  MYSTUDENTID

32 C# Reserved Words C# Language Overview 31

33 More Resources  How Bits and Bytes Work (http://www.howstuffworks.com/bytes.htm)http://www.howstuffworks.com/bytes.htm  Byte (http://en.wikipedia.org/wiki/Byte)http://en.wikipedia.org/wiki/Byte  Computer hardware (http://en.wikipedia.org/wiki/Computer_hardware)http://en.wikipedia.org/wiki/Computer_hardware  Software (http://en.wikipedia.org/wiki/Software)http://en.wikipedia.org/wiki/Software  Programming language (http://en.wikipedia.org/wiki/Programming_language)http://en.wikipedia.org/wiki/Programming_language  List of programming languages (http://en.wikipedia.org/wiki/List_of_programming_la nguages)http://en.wikipedia.org/wiki/List_of_programming_la nguages 32

34 Any question?


Download ppt "Introduction to Computer and Programing Thanachat Thanomkulabut."

Similar presentations


Ads by Google