INC 161 , CPE 100 Computer Programming

Slides:



Advertisements
Similar presentations
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and.
Advertisements

Lecture 1: Overview of Computers & Programming
CSE Spring 2015 INTERMEDIATE PROGRAMMING
C Programming for engineers Teaching assistant: Ben Sandbank Home page:
INTRODUCTION T.Najah Al_Subaie Kingdom of Saudi Arabia Prince Norah bint Abdul Rahman University College of Computer Since and Information System CS240.
COSC 120 Computer Programming
Software Lesson #1 CS1313 Spring Software Lesson 1 Outline 1.Software Lesson 1 Outline 2.What is Software? A Program? Data? 3.What are Instructions?
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Introduction to Computer Science I.
Program Translation Module 6. Mid-Term Results.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
INC 111 Basic Circuit Analysis
C++ Programming Language Day 1. What this course covers Day 1 – Structure of C++ program – Basic data types – Standard input, output streams – Selection.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
Computer Science 101 Introduction to Programming.
CS1430: Programming in C++ Section 2 Instructor: Qi Yang 213 Ullrich
1 Lecture 2 : Computer System and Programming. Computer? a programmable machine that  Receives input  Stores and manipulates data  Provides output.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Variables 1.
CIS Computer Programming Logic
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008.
Computer Programming Basics Assistant Professor Jeon, Seokhee Assistant Professor Department of Computer Engineering, Kyung Hee University, Korea.
INC 112 Basic Circuit Analysis Lecturer Assistant Prof. Dr. Poj Tangamchit.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 1 Introduction to Computers and Programming.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
1 Agenda Administration Background Our first C program Working environment Exercise Memory and Variables.
Computer Programming I. Today’s Lecture  Components of a computer  Program  Programming language  Binary representation.
Implementation of a Stored Program Computer ITCS 3181 Logic and Computer Systems 2014 B. Wilkinson Slides2.ppt Modification date: Oct 16,
Introduction to Computer Systems and the Java Programming Language.
Summary of what we learned yesterday Basics of C++ Format of a program Syntax of literals, keywords, symbols, variables Simple data types and arithmetic.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 1 February 8, 2005.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
1 Lecture 2 : Computer System and Programming. Computer? a programmable machine that  Receives input  Stores and manipulates data  Provides output.
Introduction to Programming Instructor: Yong Tang Brookhaven National Laboratory Working on accelerator control (BNL Phone #)
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
The Hashemite University Computer Engineering Department
Dr. Sajib Datta CSE Spring 2016 INTERMEDIATE PROGRAMMING.
Scott Marino MSMIS Kean University MSAS5104 Programming with Data Structures and Algorithms Week 1 Scott Marino.
Dr. Sajib Datta Jan 15,  Instructor: Sajib Datta ◦ Office Location: ERB 336 ◦ Address: ◦ Web Site:
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
INTRODUCTION TO PROGRAMING System Development Mansoura October 2015.
CMPT 201 Computer Science II for Engineers
General information Course web page:
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Computer Engineering Department Islamic University of Gaza
Chapter 1: Introduction to computers and C++ Programming
Hardware and Software Hardware refers to the physical devices of the computer system e.g. monitor, keyboard, printer, RAM etc. Software is a set of programs,
Final exam: Wednesday, March 20, 2:30pm
GC101 Introduction to computers and programs
Microprocessor Systems Design I
Computer System and Programming
Revision Lecture
CSE1320 INTERMEDIATE PROGRAMMING
CSE1320 INTERMEDIATE PROGRAMMING
Programming COMP104: Fundamentals and Methodology Introduction.
Administrative things
CSE1320 INTERMEDIATE PROGRAMMING
CSE1320 INTERMEDIATE PROGRAMMING
CS190/295 Programming in Python for Life Sciences: Lecture 1
CSCE Fall 2013 Prof. Jennifer L. Welch.
Lecture 18 Arrays and Pointer Arithmetic
CSE1320 INTERMEDIATE PROGRAMMING
Topics Introduction Hardware and Software How Computers Store Data
CSE1320 INTERMEDIATE PROGRAMMING
Syllabus.
CSCE Fall 2012 Prof. Jennifer L. Welch.
INC 161 , CPE 100 Computer Programming
Summary of what we learned yesterday
ICS103 Programming in C 1: Overview of Computers And Programming
Getting Started With Coding
Presentation transcript:

INC 161 , CPE 100 Computer Programming Lecturer Associate Prof. Dr. Poj Tangamchit

About the Instructor Office: CB40603 (CB4 6th floor) Control System and Instrumentation Eng. (INC) Tel: x-9094 E-mail: poj.tan@kmutt.ac.th Research Interest: Robotics, Artificial Intelligence (AI)

Course Details 3 Credits 2 credits Lecture + 1 credits Practice Class time 4 hours / week 2 hours lecture + 2 hours lab Review + Homework 6-12 hours/week Teaching Style = Self Lecture + Practice

Scoring & Grading Midterm Exam 40% Final Exam 40% Homework 15% In-class attendance 5 % Grading follows the faculty of Engineering’s standard procedure.

Homework & Assignment Homework takes time. Allocate 6-12 hours each week for it. Students need self-practice outside class time.

Copy of Homework (Plagiarism) Students should do their homework separately. If two or more students have similar homework, they will get homework score = -100%, no matter who is the original. Program codes will be checked by INC-MOSS (Measure Of Software Similarity developed by INC) This is our standard used for judge copying.

Textbooks Schaum's Outline of Programming with C, 2nd Edition By Byron S. Gottfried ISBN-139780070240353

Class Webpage http://www.inc.eng.kmutt.ac.th/inc161 Announcement Lecture Slides Facebook discussion group https://www.facebook.com/groups/138077300115052/

What is a computer? Computer = Data Processing Machine

Why computers are important? Document Processing High-Tech Machine Control Mobile Embedded Devices

Computer Specification

HDD, Ram, Cache are data storage CPU is data processing unit Hard disk Ram Cache CPU

What is inside RAM?

Real World representation of data ‘0’ is represented by voltage 0 volts ‘1’ is represented by voltage 5 volts (TTL level)

How much data? 1 bit = 1 unit of data (can be represent as ‘0’ or ‘1’) 1 byte = 8 bit 1 kilobyte = 1024 bytes 1 megabyte = 1024 kilobytes

‘0’ and ‘1’ can represent everything Number - 33, 55, 1.2332 Word, Sentence - .txt .doc Picture - .jpg .bmp Video - .mpg .avi Sound - .wav .mp3

Functionality of the CPU Command 001101110101 Input 0011010101 0101010000 1001010101 0101010001 0101010110 0010101000 Output CPU 001101110101 010101011000

The purpose of this course Know how to give commands to the CPU to make it work as we want. CPU 0011010101 0101010000 1001010101 0101010001 0101010110 0010101000 001101110101 010101011000 Input Output Command

Machine Language(Code) for 32-bit OS 32 digits Add - 01010010010100100101001001010010 Subtract- 11010110110100100101001001010111 Multiply- 00010110100100100100001001010000 Division- 10010010110100100101001000010001 :

Hard to remember? Suppose we want to command the CPU Add Add Subtract Multiply What is the code?

Compiler Compiler translates a language to machine code. 010101000010010101010010001010101010010101010100001010010010100 Add Subtract Compiler

Computer Programming Languages Three types of programming languages Machine code or machine languages A sequence of 0’s and 1’s giving machine specific instructions Example: 00011001 2. Assembly language Using meaningful symbols to represent machine code. Example: add hl,de Assembler: Assembly code  machine code Disassembler: machine code  assembly code

Computer Programming Languages 3. High-level languages Similar to everyday English and use mathematical notations (processed by compilers or interpreters) Example of a C statement: a = a + 8;

Computer Programming Languages 3. High-level languages Similar to everyday English and use mathematical notations (processed by compilers or interpreters) Example of a C statement: a = a + 8;

Comparison of High-Level Language with Machine Code and Assembly Code The memory addresses, machine code, and assembly code corresponding to a C statement a = a + 8 for the Rabbit 3000 8-bit microprocessor. Memory address Machine code Assembly code ------------------------------------------------------------------------------------- 0X1EA1 000100010000100000000000 ld de,0x0008 0X1EA4 1100010000000000 ld hl,(sp+0) 0X1EA6 00011001 add hl,de 0X1EA7 1101010000000000 ld (sp+0),hl

Topics CPU Expression Operation Data type: int float char Flow Control if for while Function Data type: int float char Array Pointer Structure CPU 0011010101 0101010000 1001010101 0101010001 0101010110 0010101000 001101110101 010101011000 Input Output Command

How can we give commands to a computer? By running the program .exe = executable program .txt = text file .jpg = pictures .avi = audio+video file

C Programming Language

Command Compiler translates a language to machine code. 010101000010010101010010001010101010010101010100001010010010100 Add Subtract Compiler Learn this format

C Program Structure main () { } Put commands in here

Variable Declaration We can define a part of memory to store data. We can give a name to it. Later, we can refer to it by this name. However, a name must not be reserved words.

int = integer float = floating point char = character Follow with variable name e.g. int a; (Every command in C must end with semi-colon)

Sample Program main () { int i; float val; char ww; }

Inside Memory 001111111 ww 00110000 val 00000000 i Cache, Ram, HDD

Reserved Words

Comments Comments of a C program can be enclosed within a pair of delimiters /* and */. The symbol // will comment out a subsequent text terminated at the end of a line. /* This is a comment */ /* This is a comment across multiple lines */ printf(”Hello, world\n”); // This is a comment (terminated at the end of line)