Introduction to basic programming Kai Zang Jul 2 nd, 2012.

Slides:



Advertisements
Similar presentations
Fundamentals of Computer and programming in C Programming Languages, Programs and Programming Rohit Khokher.
Advertisements

Module 6: Introduction to C Language ITEI102 Introduction to Programming Structure of C++ Program - Programming Terminologies - Microsoft Visual Studio.
Introduction to Programming Lecture 2. Today’s Lecture Software Categories Software Categories System Software System Software Application Software Application.
Programming recap. Do you know these? LOW LEVEL 1 st generation: machine language (110011) 2 nd generation: assembly language (ADD, SUB) HIGH LEVEL 3.
COSC 120 Computer Programming
Wednesday, 9/4/02, Slide #1 1 CS 106 Intro to CS 1 Wednesday, 9/4/02  Today: Introduction, course information, and basic ideas of computers and programming.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
If You Missed Last Week Go to Click on Syllabus, review lecture 01 notes, course schedule Contact your TA ( on website) Schedule.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
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.
Why Program? Computer – programmable machine designed to follow instructions Program – instructions in computer memory to make it do something Programmer.
Chapter Introduction to Computers and Programming 1.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
CIS Computer Programming Logic
CSC141 Introduction to Computer Programming
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Computer Engineering 1 nd Semester Dr. Rabie A. Ramadan 2.
Introduction to Computer Systems and the Java Programming Language.
Evolution and History of Programming Languages. Machine languages Assembly languages Higher-level languages To build programs, people use languages that.
Evolution and History of Programming Languages. Software Programming Language.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 1 February 8, 2005.
Lecture #5 Introduction to C++
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
COMPUTER PROGRAMMING. A Typical C++ Environment Phases of C++ Programs: 1- Edit 2- Preprocess 3- Compile 4- Link 5- Load 6- Execute Loader Primary Memory.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Typical C++ Environment and Library Introduction Speaker : Wei-Lu Lin Advisor : Ku-Yaw Chang 2012/10/14.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
CHAPTER 1: INTRODUCTION C++ Programming. CS 241 Course URL: Text Book: C++ How to Program, DETITEL & DEITEL, eighth Edition.
Week 1 Lecture 2SE1SA51 Introducing C SE1SA5 Sue Walmsley.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
C is a high level language (HLL)
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming Dr. Halla Abdel Hameed.
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
Introduction to C Programming
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Hello world !!! ASCII representation of hello.c.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
INTRODUCTION TO PROGRAMING System Development Mansoura October 2015.
Software Engineering Algorithms, Compilers, & Lifecycle.
Introduction to Programming By: Prof. Muhammad Abu Baker Siddique 2 nd Lecture 1.
1 CS 192 Lecture 4 Winter 2003 December 8-9, 2003 Dr. Shafay Shamail.
Chapter 1: Introduction to Computers and Programming
Chapter 1 Introduction 2nd Semester H
BASIC PROGRAMMING C SCP1103 (02)
Chapter 1: An Overview of Computers and Programming Languages
Chapter 1: Introduction to computers and C++ Programming
BASIC PROGRAMMING C SCP1103 (02)
Computer Engineering 1nd Semester
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
Chapter 1: Introduction to Computers and Programming
פרטים נוספים בסילבוס של הקורס
CSCE Fall 2013 Prof. Jennifer L. Welch.
Hardware & Software Programming. COMP102 Prog. Fundamentals I: Software / Slide 2 l Four components of a computer system: n CPU - central processing unit.
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
CSCE Fall 2012 Prof. Jennifer L. Welch.
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
C Language B. DHIVYA 17PCA140 II MCA.
Introduction to C Programming
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

Introduction to basic programming Kai Zang Jul 2 nd, 2012

Introduction Programming: one of the tools that you can change lives around you – Want to find if a picture has been photoshoped? – Robot, mindrover – Game development? For this lecture, the grammar will be based upon C. The contents will ONLY cover our basic use for Arduino.

What’s inside a PC? Central processing unit Memory(ROM)Memory(RAM) Input device (keyboard, mouse, gamepads) Output device (head phones, monitor)

What about our Teensy??? Central processing unit Memory(ROM)Memory(RAM) Input device (sensors, buttons, knobs) Output device (head phones, monitor) What if we want to design TAIKO DRUM MASTER?!

So let’s go in further… What’s inside a memory? Bit: smallest unit, 1 bit reprensent 0 or 1 Byte = 8 bits 1kb = 1024 bytes 1Mb=1024 kb 1Gb=1024Mb A typical 6*5 memory array

How do we use bits to represent variable & constant? Variable & constant both name a place in memory where you store a Value of a certain Type. Their difference: the Value of Variable can be changed, but constant cannot. How to represent value with bits? Use binary or hexadecimal: ( ) 2 = (2c) 16 =(44) 10 For a series of n bits, we may represent 2 n number in total.

Then what about data type? Int (integer, 4 bytes) – Signed: to – Unsigned: 0 to Double (double precision floating point number, 8 bytes) Char (character, 1 bytes, ACSII) bool (boolean value, 1 bytes, true/false)

To represent character ‘a’ in memory ‘Var_name’ will occupy address From (1,1) to (2,3) in our 5*6 Memory. (97) 10 =(61) 16 =( ) 2 Syntax: Char var_name = ‘a’; Const int var_name_2 = 12;

Will these make any sense? Now let’s see in contra, we use ‘Hack’ to make our hero undead.

Syntax The following are examples: Float x; Int y=10; Char letter=‘a’; char letter=97; Int num[4]={1,2,3,4}; Char s[5]={‘a’,’b’,’c’,’d’,’e’}; // the size of array is fixed since its creation Definition of ‘=‘ y=y+1; //now y has become 11 letter = letter + 2; //now letter has become ‘c’ S[1]= s[1]+2; // can comment a line /* Can comment a paragrah */

Syntax for operator Introduce some of the most basic: – Int x=5, y=2; – Printf(x/y); //output is 2, larger integer < 2.5 – Printf(x%y); //% can only be used with integer module integer, output is 1 – Int x=5; – Double y=2; – Printf(x/y); //output is 2.5

Now comes logic commands Sequence – Commands are run in sequence Int counter=1; Counter = counter + 1; Counter = counter + 2; Selection – check to see if condition is met. If yes, run. If no, run otherwise. Int counter = 1; If (counter != 1) {counter=counter+1;} Else {counter = counter+2;}

Logic commands (cont.) Loop (for) for(initial condition; end condition; loop commands) Example: For(i=1; i<5; i=i+1) { result=a+b; // i=i+2; } Loop (while) While(ending condition) i=1; While(i<5) { result=a+b; i=i+1; }

We plan to make modules for a program and so comes function A Function is a series of instructions to run. You pass Arguments to a function and it returns a Value. Syntax: Return_type function_name(argument1, argument2…) Int addition(int a, int b) { Int result=a+b; Return result; } Int result = addition(2, 3); // then result=5

Memory use for function Let’s see what happened when run? Int addition(int a, int b) { Int result=a+b; Return result; } Int result = addition(2, 3); // then result=5 We will come about the definition of global variable, local variable when introducing Arduino later. a b result

One step back: machine language Machine language – That machines can directly read, mianly 0/1 Assembly language – That becomes easier to work with Higher-level language – C, C++, Java, Pascal, BASIC Fourth generation language – Visual basic(VB) Assembler Assembly code Object code

1.Edit 2.Preprocess 3.Compile 4.Link 5.Load 6.Execute Disk Loader Linker Compiler Preprocessor Editor Disk Primary Memory CPU Primary Memory 1.Program is created in the editor and stored on disk 2.Preprocessor program processes the code 3.Compiler creates object code and stores it on disk. 5.Loader puts program in memory. 4. Linker links the object code with the libraries 6.CPU takes each instruction and executes it, possibly storing new data values as the program executes Phases of C Programs: A Typical C Program Development Environment

A powerful tool: flow chart I do not make ppt for this part but download an introductory ppt from Internet. Just search ‘programming flow chart’ in Google.

Thanx for your time!!! XD Any Qs?