1 / 33

Introduction to Computer and Programing

Learn the fundamentals of computers, hardware components, storage, and programming languages like C#. Understand data representation and language structures.

kershner
Download Presentation

Introduction to Computer and Programing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Computer and Programing Thanachat Thanomkulabut

  2. Outline • Introduction to computer • Programming Languages • C# Language Overview

  3. Introduction to computer Definition of Computer • 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”

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

  5. Introduction to computer Computer Systems • Hardware • Actual physical machines (equipment) that make up the computer • Software • Programs written for a specific application are often called softwares

  6. Introduction to computer Computer Components CPU (Central Processing Unit) Primary storage (memory) Secondary storage (disks, tapes, etc.) Input devices (mouse, keyboard, etc.) Output devices (screen, printer, etc.)

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

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

  9. Introduction to computer Data Representation • 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 = 210 = 1024 bytes 1 Mbyte = 220 = 1,048,576 bytes 1 Gbyte = 230 = 1,073,741,824 bytes 1 Tbyte = 240 = 1,099,511,627,776 bytes

  10. ASCII Table

  11. Outline • Introduction to computer • Programming Languages • C# Language Overview

  12. Programming Languages Programming Languages • 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

  13. Programming Languages High-level VS Assembly VS Machine Language • High-level Language • Nearly like human word SUM := A * 2 + ALPHA/3; • Assembly Language • Some key words are understandable MULL3 A, #2, R ADDL3 R6, R7, SUM • Machine Language • Only “0” and “1” 00011000011 00011001111 10011000111 Computer itself understands only Machine language

  14. Programming Languages Language translator Interpreter / Compiler • High-level language • static void Main( ){ • Console.WriteLine("Hello World!");} • Assembly language • pushl %ebpmovl %esp, %ebpsubl $8, %espandl $-16, %esp Assembler • Machine language • 000110001100011100011000111010111100011000110001110 Machine Hello World! _

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

  16. Outline • Introduction to computer • Programming Languages • C# Language Overview

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

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

  19. C# Language Overview A simple C# Program C# syntax is case-sensitive namespace NAMEspace Main() main()

  20. C# Language Overview A simple C# Program White space means nothing static voidMain(string[] args) { Console.WriteLine("Hello World!"); } static voidMain(string[] args){ Console.WriteLine("Hello World!");}

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

  22. C# Language Overview 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 ... }

  23. C# Language Overview Class Class namespace 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

  24. C# Language Overview 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(); } } }

  25. C# Language Overview 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

  26. C# Language Overview Naming Rules • Letters, digits and underscores(_) • First character must be a letter or _ • Up to 63 characters long • Must not be a reserved word Example name Name point9 9point _data class_A class_"A" class

  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

  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.

  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); } }

  30. Notes for Identifiers • Identifiers are case-sensitive • mystudentId • Mystudentid • MYSTUDENTID

  31. C# Language Overview C# Reserved Words

  32. 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)

  33. Any question?

More Related