Imperative Programming

Slides:



Advertisements
Similar presentations
Etter/Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 1 Engineering Problem Solving.
Advertisements

Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
C Programming for engineers Teaching assistant: Ben Sandbank Home page:
Introduction to C Programming CE Lecture 1 Introduction to C.
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 –
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
1 ICS103 Programming in C Lecture 2: Introduction to C (1)
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez
By: Mr. Baha Hanene Chapter 3. Learning Outcomes We will cover the learning outcome 02 in this chapter i.e. Use basic data-types and input / output in.
Computer Science 210 Computer Organization Introduction to C.
1 Software John Sum Institute of Technology Management National Chung Hsing University.
C Programming Lecture 3. The Three Stages of Compiling a Program b The preprocessor is invoked The source code is modified b The compiler itself is invoked.
Chapter 5: Data Input and Output Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills
CISC105 General Computer Science Class 1 – 6/5/2006.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
1 Agenda Administration Background Our first C program Working environment Exercise Memory and Variables.
Programming With C.
1 計算機程式設計 Introduction to Computer Programming Lecture01: Introduction and Hello World 9/10/2012 Slides modified from Yin Lou, Cornell CS2022: Introduction.
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
Introduction to Computer Systems and the Java Programming Language.
Introduction to Programming
The Software Construction Process. Computer System Components Central Processing Unit (Microprocessor)
Khalid Rasheed Shaikh Computer Programming Theory 1.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
A.Abhari CPS1251 Topic 1: Introduction to Computers Computer Hardware Computer components Connecting Computers Computer Software Operating System (OS)
9/29/99B-1 CSE / ENGR 142 Programming I Variables, Values, and Types © 1998 UW CSE.
Department of Electronic & Electrical Engineering Introduction to C - The Development cycle. Why C? The development cycle. Using Visual Studio ? A simple.
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the basic properties and characteristics of external files ❏ To.
INTRODUCTION TO PROGRAMING System Development Mansoura October 2015.
Operating Systems A Biswas, Dept. of Information Technology.
Introduction to Programming By: Prof. Muhammad Abu Baker Siddique 2 nd Lecture 1.
BASIC PROGRAMMING C SCP1103 (02)
CSCE 206 Structured Programming in C
Computer Science 210 Computer Organization
ECE Application Programming
Engineering Problem Solving With C An Object Based Approach
Chapter 7 Text Input/Output Objectives
Chapter 7 Text Input/Output Objectives
A bit of C programming Lecture 3 Uli Raich.
INC 161 , CPE 100 Computer Programming
BASIC PROGRAMMING C SCP1103 (02)
Chapter 7 Text Input/Output Objectives
Introduction to C Language
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Getting Started with C.
The Software Construction Process
Lecture2.
Imperative Programming
Choice of Programming Language
B. Ramamurthy University at Buffalo
Administrative things
Visit for more Learning Resources
Computer Science 210 Computer Organization
B. Ramamurthy University at Buffalo
Computer Science I CSC 135.
B. Ramamurthy University at Buffalo
I/O in C Lecture 6 Winter Quarter Engineering H192 Winter 2005
Software John Sum Institute of Technology Management
Introduction to CS Your First C Programs
פרטים נוספים בסילבוס של הקורס
B. Ramamurthy University at Buffalo
פרטים נוספים בסילבוס של הקורס
B. Ramamurthy University at Buffalo
C programming Language
Introduction to C Programming
Let’s start from the beginning
Course Outcomes of Programming In C (PIC) (17212, C203):
Presentation transcript:

Imperative Programming A 5 ECTS course for for first year students http://www.control.aau.dk/~jdn/edu/courses/e10/imperativ Based on “C”

Goal Learn how to program with an imperativ language. “C” Do it in real life on your PC Install of SW like compilers Get things up and running Use it in P1 project if possible Get an programming skill platform for the next languages to come to you (java, C++,C#,Python,Php,matlab,...)

Goal II

Rough layout of course Basic C and programming Embedded programming on Arduino Ask your supervisor for an Arduino pr group And maybe buy one you self (200 DKK) http://arduino.cc

Basic C part On a tradional basis – editor,compiler, run an executable No fansy GUI etc GUI based: Eclipse,... The war of operating systems Mac, Windows XP/V/7, Linux, embedded We try to cover it all Please help your neighbour

Embedded part Arduino based AVR micro controller 1/2/4/8 kByte of RAM Up to 128 kByte of flash for program code IO Up to 14 channels 10 bit analog input Up to 7 or so analog output (by PWM) Digital in and out – a lot Serial (rs232),i2c,.. Use nearly no current (use a battery) Cheap

Arduino's

It is your choice To be here We are here to help (you)

TODAY Chapter 1 Chapter 2 Exercises

Den gang far var ung ... Var der rigtige kompjutere til

Characteristics Difficult to program Difficult to run programs on High salaries Died after the PC arrived ? 64 kByte Ram 4.77 Mhz processor (today 1000 times more) 1 or 2 640 kByte floppy drive

The return of the main frame ?!

Very simple model GUI IO NET IO OS HW

From code to executable Editor – write program in language (C,...) Compile it to binary for a specific architecture (PC,ARM,...) Link it with libraries for specific platform windows,linux,arduino,... Different platforms different facilities/possibilities Save executable In filesystem (on “disk”) In flash memory Loadable via net ...

Let's do it /* A simple Program */ #include <stdio.h> int main(void) { printf(“Hello World\n”); }

SW Development method Specify problem requirements Analyze the problem Design the algorithm to solve the problem Implement the algorithm Test and verify the completed program Maintain ... and update the program Very simplified ...

Fig 2.1 ... on the comming slides C is en general a very small language No fancy graphics, GUI, network,... All extra is by purpose on a specific platform And is supplied in libraries/part of Operating Sys

Only simple types: Integers : 16/32/64 bit wide dep of architecture Floating point: IEEE given character/byte 8 bit void (nothing) ...

/* include statements – for extending “language”*/ #include <stdio.h> /* standard input/output stuff */ /* C can only + - * / /* the rest comes as library / “extensions” */ Sin, cos, atan, printf, file I/O, GUI (!),...

double float_1; int int_1, int_2; /* upper case is not equal lower case */ int main(void) { int_1 = 3; int_2 = int_1 *3 – 44; float_1 = int_1; } /* p.. of cake */

Beware about conversions /* declaration part */ int i_1, i_2, i_3; double float_1; i_1 = 3; i_2 = 4; i_3 = i_1 / i_2; float_1 = i_1 / i_2; /* ??? */

int int1, int2; ... int2 = 12785; Int1 = int2 ; /* an assigment is a copy !!! */

stdio.h Need something one the computer screen ... Output like print “hello ...” Input like “read_an_integer_from_keyboard

stdio.h - output printf (“hello”); printf (“hello\n new line”); printf(“hello – I have %i legs “ , 2 ); printf(“ hello – I have %&i legs” , int_1) ; %i : integer %f : floating point %c : character + variants : %3i Integer written out as xxx

printf (“ %i %f %c”, 3, 3.2 , 3 ); int i,j,k; i = 3 ; j = 4; k = 4444; printf(“%i%i%i”, i,j,k); /* writes out 344444 */ printf(“%i %i %i”, i,j,k); /* writes out 3 4 4444 */

stdio.h - input read from keyboard No error handling today I ask for an integer you type dumpkopf ...

stdio.h - scanf int a_number; scanf ( “%i “, & a_number); /* read & as location or address */ /* i for int, f for float c for character – as printf*/

int i1,i2,i3; scanf(“%i %i %i”, & i1, &i2, &i3 ) ;

Operator Hierarchy See inside first page in book and page 96.. Level x + - Level x-1 * / ... 2 + 5 * 4 + 5 = ??? 27 I guess

(())(()) Use ( ) to clarify: ((2*3) +5) / (3+7) You can never use to many – only to few ...