Slide Set 1. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Size: px
Start display at page:

Download "Slide Set 1. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary"

Transcription

1 Slide Set 1 for ENCM 339 Fall 2016 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2016

2 ENCM 339 Fall 2016 Slide Set 1 slide 2/43 Contents About these slides Writing and running a very simple C program The return value from main Input and output of int values with scanf and printf C code organization for the first few weeks of 339 Activation Records and the Stack Syntax for C function definitions True and False in C

3 ENCM 339 Fall 2016 Slide Set 1 slide 3/43 Outline of Slide Set 1 About these slides Writing and running a very simple C program The return value from main Input and output of int values with scanf and printf C code organization for the first few weeks of 339 Activation Records and the Stack Syntax for C function definitions True and False in C

4 ENCM 339 Fall 2016 Slide Set 1 slide 4/43 About these slides This is the first of around ten to twelve large sets of slides that will be used for lectures in Section 01 of ENCM 339 in Fall It will usually take several lectures to get through a single set of slides. For example, I expect that it will take about three lectures to get through this first set. Reading these slides online is not a good substitute for attending lectures in most lectures I will do some important hand-written work using the document camera. Please come to lectures prepared to take some notes.

5 ENCM 339 Fall 2016 Slide Set 1 slide 5/43 Typographical conventions Either bold text or bright red text will be used for emphasis. The typewriter font will usually be used for code in C or C++. (I might not use the typewriter font for code if it makes the code too wide to fit in a slide.) Text in a box is a general description of what could appear within a piece of code. Example: A C do statement has this syntax... do statement while ( expression ); (Usually statement is a compound statement that starts with { and ends with }.)

6 ENCM 339 Fall 2016 Slide Set 1 slide 6/43 Typographical conventions: Italics Italics will be used two different ways. One word or a few words in italics will be used to formally or informally define a term. Example: A loop is a part of a program that allows repeated execution of a list of statements. An entire sentence in italics indicates a pause to elaborate a concept or solve a problem under the document camera. Example: Let s rewrite the for loop as a while loop.

7 ENCM 339 Fall 2016 Slide Set 1 slide 7/43 Outline of Slide Set 1 About these slides Writing and running a very simple C program The return value from main Input and output of int values with scanf and printf C code organization for the first few weeks of 339 Activation Records and the Stack Syntax for C function definitions True and False in C

8 ENCM 339 Fall 2016 Slide Set 1 slide 8/43 Writing and running a very simple C program Let s pretend that we have no idea what and are, that we need to know those values, and that the only way we can find out is to write a C program that will give us the answers. That s obviously silly! But it s a quick way to create a tiny example programming problem. The next slide has C source code to solve the problem. Let s make some notes about the source code.

9 ENCM 339 Fall 2016 Slide Set 1 slide 9/43 #include <stdio.h> // note 3 int add(int left, int right); // note 1 int main(void) { int sum; sum = add(2, 3); // note 2 printf("the first sum is %d.\n", sum); sum = add(4, 7); // also note 2 printf("the second sum is %d.\n", sum); return 0; } int add(int left, int right) // note 4 { return left + right; }

10 ENCM 339 Fall 2016 Slide Set 1 slide 10/43 Source code and executable files Source code for a program is code written by one or more humans, in a programming language such as C. Early in ENCM 339, the source code for a C program will be a single file, with a.c extension at the end of its name. (Later, we ll learn how to organize source code in multiple files.) An executable file contains machine code: lists of instructions in a language that a computer processor chip can understand.

11 ENCM 339 Fall 2016 Slide Set 1 slide 11/43 Pay attention to which folder you re working in! It s important to make sure that these two things are the same... the folder you save your C source code; the current working directory of the terminal window you use to build and run the executable file. (Note that directory is a synonym for what most Windows and Mac users would call a folder.) Please see the Lab 1 instructions and related documents for details on how to change the current working directory in terminal window.

12 ENCM 339 Fall 2016 Slide Set 1 slide 12/43 Editing source code, building and running an executable The next few slides show to create a source file for our example C program, then how to build an executable and run it. The very next slide shows a text editor window, after the C code has been typed in and saved to a file called add.c.

13

14 ENCM 339 Fall 2016 Slide Set 1 slide 14/43 Below is a screenshot of a Cygwin terminal window. Cygwin is the environment we ll use in the lab for building and testing executables. Let s make some notes about what has happened so far in this example terminal window.

15 ENCM 339 Fall 2016 Slide Set 1 slide 15/43 The screenshot here is a continuation of the example on the previous slide. What new thing has just happened?

16 ENCM 339 Fall 2016 Slide Set 1 slide 16/43 Outline of Slide Set 1 About these slides Writing and running a very simple C program The return value from main Input and output of int values with scanf and printf C code organization for the first few weeks of 339 Activation Records and the Stack Syntax for C function definitions True and False in C

17 ENCM 339 Fall 2016 Slide Set 1 slide 17/43 The return value from main This is a minor detail, but I ve found that if I don t discuss it, I get questions about it. In both standard C and standard C++, main is a function that returns an int value. (Some C and C++ systems allow a return type of void for main, but that s non-standard, so we won t do that in ENCM 339.) The return value from main is used to communicate information from a program back to the operating system that launched the program: returning 0 means the program succeeded ; return a non-zero value says the program failed.

18 ENCM 339 Fall 2016 Slide Set 1 slide 18/43 Outline of Slide Set 1 About these slides Writing and running a very simple C program The return value from main Input and output of int values with scanf and printf C code organization for the first few weeks of 339 Activation Records and the Stack Syntax for C function definitions True and False in C

19 ENCM 339 Fall 2016 Slide Set 1 slide 19/43 Input and output of int values with scanf and printf The first few lectures in ENCM 339 are designed to teach you all the C features you need to do Lab 1. So we ll jump quickly through some key features of C. We ll return to some of these features later in the course, and examine them in much greater depth. Let s look first at these two things: getting input of int values from the terminal, using the scanf function; sending output of int values to the terminal, using the printf function. The next slide has a simple example program.

20 ENCM 339 Fall 2016 Slide Set 1 slide 20/43 #include <stdio.h> int main(void) { int a, b; printf("please enter an int:\n"); scanf("%d", &a); printf("please enter another int:\n"); scanf("%d", &b); printf("%d plus %d is %d.\n", a, b, a + b); return 0; } Let s copy the program so we can think about all of its pieces. Then let s write out an example dialogue with the program.

21 ENCM 339 Fall 2016 Slide Set 1 slide 21/43 Questions about the use of scanf scanf("%d", &a); 1. What does %d mean? Are there other uses of % for other types of input data? 2. Why is & necessary in front of a? 3. What happens if the user types letters or punctuation instead of digits? 4. Is there is a way to check for input errors?

22 ENCM 339 Fall 2016 Slide Set 1 slide 22/43 Notes on the call to printf printf("%d plus %d is %d.\n", a, b, a + b); What s going on here? We had to use &, the address-of operator, in the scanf call. Why don t we use it in the printf call?

23 ENCM 339 Fall 2016 Slide Set 1 slide 23/43 Outline of Slide Set 1 About these slides Writing and running a very simple C program The return value from main Input and output of int values with scanf and printf C code organization for the first few weeks of 339 Activation Records and the Stack Syntax for C function definitions True and False in C

24 ENCM 339 Fall 2016 Slide Set 1 slide 24/43 C code organization for the first few weeks of 339 Most real world C programs are written as a collection of.c and.h files. But we ll start with programs written in single.c files that have this layout: #include directives function prototypes definition of main definitions of other functions There s an example on the next slide. Let s copy the example and make some notes about it.

25 #include <stdio.h> int larger(int a, int b); int main(void) { int x = 3, y = 7, z; z = larger(x, y); printf("the larger of %d and %d is %d.\n", x, y, z); return 0; } int larger(int a, int b) { int result = a; if (b > a) result = b; return result; }

26 ENCM 339 Fall 2016 Slide Set 1 slide 26/43 Outline of Slide Set 1 About these slides Writing and running a very simple C program The return value from main Input and output of int values with scanf and printf C code organization for the first few weeks of 339 Activation Records and the Stack Syntax for C function definitions True and False in C

27 ENCM 339 Fall 2016 Slide Set 1 slide 27/43 Activation Records and the Stack This is a big ENCM 339 topic that is not covered in detail in textbooks. Careful attention to lectures and to documents posted on D2L is essential. What we re about to study is a model for how C and C++ functions manage their local variables and function arguments. This model will be very helpful in understanding how a wide range of C and C++ features work.

28 ENCM 339 Fall 2016 Slide Set 1 slide 28/43 What does it mean for a function to be active? This is a important definition: A function is active if its code is currently being executed or if it is waiting for a function call to return. Examples: Let s decide which functions are active at points 1, 2, and 3 in our most recent example program.

29 ENCM 339 Fall 2016 Slide Set 1 slide 29/43 Activation records Each active function has an activation record ( AR ) in which arguments and local variables are stored. An AR is created automatically when a function becomes active; disappears when the function stops being active. ARs are stored in a region of program memory called the stack (or, sometimes, the function call stack).

30 ENCM 339 Fall 2016 Slide Set 1 slide 30/43 Memory diagrams A major activity in 339 will be drawing diagrams to illustrate memory use by C and C++ programs. Please use the course conventions for memory diagrams that will be introduced as 339 progresses. Let s make memory diagrams for points 1, 2, and 3 in our most recent example program, then make a couple of remarks.

31 ENCM 339 Fall 2016 Slide Set 1 slide 31/43 Some conventions for drawing memory diagrams We ll start with these rules: start with AR of main at the bottom of the stack; put arguments in the lower part of the AR; put local variables in the upper part of the AR; use?? to indicate uninitialized (and therefore unknown) values. We ll introduce more conventions later in the course.

32 ENCM 339 Fall 2016 Slide Set 1 slide 32/43 About Models A model is a simplified description of a natural or engineered system. A good model helps to understand and perhaps to predict the behaviour of a system. Storage of all function arguments and local variables within ARs on the stack is a simple and powerful model that helps explain important C features, such as: how arguments get passed from one function to another; how pointers work; how sequences of recursive function calls work. (Pointers are the main topic of Slide Set 2. Recursive functions will be covered toward the end of this course.)

33 ENCM 339 Fall 2016 Slide Set 1 slide 33/43 But really, not all variables and arguments are on the stack... The AR model is both vague and incorrect about how modern computer processors work with memory circuits when programs are running. That does not mean that the AR model is bad it s just not sophisticated enough to explain everything about the environment a program runs in. In reality some arguments and variables live in place called processor registers, while other arguments and variables really do live on the stack in main memory. We won t worry about those issues in ENCM 339, but we ll study them in detail in ENCM 369.

34 ENCM 339 Fall 2016 Slide Set 1 slide 34/43 Outline of Slide Set 1 About these slides Writing and running a very simple C program The return value from main Input and output of int values with scanf and printf C code organization for the first few weeks of 339 Activation Records and the Stack Syntax for C function definitions True and False in C

35 ENCM 339 Fall 2016 Slide Set 1 slide 35/43 Syntax for C function definitions return-type function name ( argument list ) block In C standard C and later C versions (and in all versions of C++), the syntax for a block is: { } mix of zero or more variable declarations and statements The C89 syntax for a block is more restrictive: { } zero or more variable declarations zero or more statements

36 ENCM 339 Fall 2016 Slide Set 1 slide 36/43 Consider this function definition: int f(int a) { int x; x = 3 * a; int y; y = a * a; return x + y; } Why is it valid code in C99 but not in C89? How could it be modified to make it valid C89? In 339, we ll usually write C blocks in the C89 style, because it provides a compact list of all the arguments and local variables a function has.

37 ENCM 339 Fall 2016 Slide Set 1 slide 37/43 Outline of Slide Set 1 About these slides Writing and running a very simple C program The return value from main Input and output of int values with scanf and printf C code organization for the first few weeks of 339 Activation Records and the Stack Syntax for C function definitions True and False in C

38 ENCM 339 Fall 2016 Slide Set 1 slide 38/43 True and False in C This is important to know when reading C code: zero stands for false; all non-zero values stand for true! Example: What is the output if foo is called with an argument bar equal to 0? Equal to 1? Equal to 1? Equal to 42? Equal to 4567? #include <stdio.h> void foo(int bar) { if (bar) printf("red\n"); else printf("blue\n"); }

39 ENCM 339 Fall 2016 Slide Set 1 slide 39/43 From the previous slide: In C, zero stands for false; all non-zero values stand for true! This rule works with many types, not just int. The example function foo would behave the same way if the type of the argument bar were double. The rule also works with pointer types. We ll be looking at pointer types in the next slide set.

40 ENCM 339 Fall 2016 Slide Set 1 slide 40/43 True and false in Processing Processing does not follow the zero means false, anything non-zero is true rule! Instead, Processing has a type called boolean. A boolean expression has one of two values: true or false. In Processing, a comparison expression like k < 3 would be of type boolean. In C, the same comparison expression would be of type int, and would have a value of 0 or 1, depending on the value of k.

41 ENCM 339 Fall 2016 Slide Set 1 slide 41/43 Comparing values The C comparison operators are the same as in Processing: ==!= < <= > >= Know the difference between = and ==... What does x = y do? And what does x == y do? Suppose k is an int with a value of 8. Let s fill in the table... expression C type C value Processing type Processing value k == 8 k!= 8 k < 8 k <= 8

42 ENCM 339 Fall 2016 Slide Set 1 slide 42/43 More examples of numbers being true or false These also serve as review of while loops, and of the difference between i-- and --i. What output is produced by each of these C code fragments? // Example 1 int i = 4; while (i) { printf("%d\n",i); i--; } // Example 2 int i = 4; while (i--) { printf("%d\n",i); } // Example 3 int i = 4; while (--i) { printf("%d\n",i); } Remark: Your instructor likes the style of Example 1 and dislikes Examples 2 and 3. Code is easier to read if testing a variable is separated from modifying the value of that variable.

43 ENCM 339 Fall 2016 Slide Set 1 slide 43/43 Connections with C++ C++ supports the C rule for representing true and false with numbers. But C++ also has these keywords: bool, a type; true and false, the two values an expression of type bool can have. in C++, a variable for the answer to a yes/no question is usually of type bool. But in C, such a variable would probably be of type int. (In C there is a way to fake the existence of a bool type, using the library header <stdbool.h>, but it doesn t get used much.)

Slide Set 2. for ENCM 335 in Fall Steve Norman, PhD, PEng

Slide Set 2. for ENCM 335 in Fall Steve Norman, PhD, PEng Slide Set 2 for ENCM 335 in Fall 2018 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2018 ENCM 335 Fall 2018 Slide Set 2 slide

More information

Contents. Slide Set 1. About these slides. Outline of Slide Set 1. Typographical conventions: Italics. Typographical conventions. About these slides

Contents. Slide Set 1. About these slides. Outline of Slide Set 1. Typographical conventions: Italics. Typographical conventions. About these slides Slide Set 1 for ENCM 369 Winter 2014 Lecture Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2014 ENCM 369 W14 Section

More information

Slide Set 3. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Slide Set 3. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary Slide Set 3 for ENCM 339 Fall 2016 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2016 ENCM 339 Fall 2016 Slide Set 3 slide 2/46

More information

Slide Set 1 (corrected)

Slide Set 1 (corrected) Slide Set 1 (corrected) for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary January 2018 ENCM 369 Winter 2018

More information

Slide Set 3. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng

Slide Set 3. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng Slide Set 3 for ENCM 339 Fall 2017 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2017 ENCM 339 Fall 2017 Section 01

More information

Slide Set 5. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Slide Set 5. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary Slide Set 5 for ENCM 339 Fall 2016 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary October 2016 ENCM 339 Fall 2016 Slide Set 5 slide 2/32

More information

ENCM 339 Fall 2017: Editing and Running Programs in the Lab

ENCM 339 Fall 2017: Editing and Running Programs in the Lab page 1 of 8 ENCM 339 Fall 2017: Editing and Running Programs in the Lab Steve Norman Department of Electrical & Computer Engineering University of Calgary September 2017 Introduction This document is a

More information

Slide Set 8. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng

Slide Set 8. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng Slide Set 8 for ENCM 339 Fall 2017 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary October 2017 ENCM 339 Fall 2017 Section 01 Slide

More information

ENCM 335 Fall 2018 Lab 2 for the Week of September 24

ENCM 335 Fall 2018 Lab 2 for the Week of September 24 page 1 of 8 ENCM 335 Fall 2018 Lab 2 for the Week of September 24 Steve Norman Department of Electrical & Computer Engineering University of Calgary September 2018 Lab instructions and other documents

More information

Slide Set 6. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng

Slide Set 6. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng Slide Set 6 for ENCM 339 Fall 2017 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary October 2017 ENCM 339 Fall 2017 Section 01 Slide

More information

Slide Set 4. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

Slide Set 4. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng Slide Set 4 for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary January 2018 ENCM 369 Winter 2018 Section

More information

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng Slide Set 1 for ENEL 339 Fall 2014 Lecture Section 02 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Fall Term, 2014 ENEL 353 F14 Section

More information

Slide Set 9. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

Slide Set 9. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng Slide Set 9 for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary March 2018 ENCM 369 Winter 2018 Section 01

More information

Contents. Slide Set 2. Outline of Slide Set 2. More about Pseudoinstructions. Avoid using pseudoinstructions in ENCM 369 labs

Contents. Slide Set 2. Outline of Slide Set 2. More about Pseudoinstructions. Avoid using pseudoinstructions in ENCM 369 labs Slide Set 2 for ENCM 369 Winter 2014 Lecture Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2014 ENCM 369 W14 Section

More information

Slide Set 4. for ENCM 335 in Fall Steve Norman, PhD, PEng

Slide Set 4. for ENCM 335 in Fall Steve Norman, PhD, PEng Slide Set 4 for ENCM 335 in Fall 2018 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2018 ENCM 335 Fall 2018 Slide Set 4 slide

More information

Slide Set 14. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Slide Set 14. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary Slide Set 14 for ENCM 339 Fall 2015 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Fall Term, 2015 SN s ENCM 339 Fall 2015 Slide Set 14 slide

More information

Slide Set 1. for ENEL 353 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Slide Set 1. for ENEL 353 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary Slide Set 1 for ENEL 353 Fall 2017 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Fall Term, 2017 SN s ENEL 353 Fall 2017 Slide Set 1 slide

More information

ENCM 335 Fall 2018 Tutorial for Week 13

ENCM 335 Fall 2018 Tutorial for Week 13 ENCM 335 Fall 2018 Tutorial for Week 13 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary 06 December, 2018 ENCM 335 Tutorial 06 Dec 2018 slide

More information

Slide Set 9. for ENCM 335 in Fall Steve Norman, PhD, PEng

Slide Set 9. for ENCM 335 in Fall Steve Norman, PhD, PEng Slide Set 9 for ENCM 335 in Fall 2018 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary October 2018 ENCM 335 Fall 2018 Slide Set 9 slide 2/32

More information

Slide Set 4. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng

Slide Set 4. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng Slide Set 4 for ENCM 339 Fall 2017 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2017 ENCM 339 Fall 2017 Section 01

More information

Slide Set 3. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

Slide Set 3. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng Slide Set 3 for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary January 2018 ENCM 369 Winter 2018 Section

More information

ENCM 339 Fall 2017: Cygwin Setup Help

ENCM 339 Fall 2017: Cygwin Setup Help page 1 of 6 ENCM 339 Fall 2017: Cygwin Setup Help Steve Norman Department of Electrical & Computer Engineering University of Calgary September 2017 Introduction This document is designed to help students

More information

Slide Set 5. for ENCM 369 Winter 2014 Lecture Section 01. Steve Norman, PhD, PEng

Slide Set 5. for ENCM 369 Winter 2014 Lecture Section 01. Steve Norman, PhD, PEng Slide Set 5 for ENCM 369 Winter 2014 Lecture Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2014 ENCM 369 W14 Section

More information

ENCM 369 Winter 2017 Lab 3 for the Week of January 30

ENCM 369 Winter 2017 Lab 3 for the Week of January 30 page 1 of 11 ENCM 369 Winter 2017 Lab 3 for the Week of January 30 Steve Norman Department of Electrical & Computer Engineering University of Calgary January 2017 Lab instructions and other documents for

More information

ENCM 339 Fall 2017 Tutorial for Week 8

ENCM 339 Fall 2017 Tutorial for Week 8 ENCM 339 Fall 2017 Tutorial for Week 8 for section T01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary 2 November, 2017 ENCM 339 T01 Tutorial

More information

ENCM 501 Winter 2015 Tutorial for Week 5

ENCM 501 Winter 2015 Tutorial for Week 5 ENCM 501 Winter 2015 Tutorial for Week 5 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary 11 February, 2015 ENCM 501 Tutorial 11 Feb 2015 slide

More information

Integer Multiplication and Division

Integer Multiplication and Division Integer Multiplication and Division for ENCM 369: Computer Organization Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 208 Integer

More information

ENCM 501 Winter 2018 Assignment 2 for the Week of January 22 (with corrections)

ENCM 501 Winter 2018 Assignment 2 for the Week of January 22 (with corrections) page 1 of 5 ENCM 501 Winter 2018 Assignment 2 for the Week of January 22 (with corrections) Steve Norman Department of Electrical & Computer Engineering University of Calgary January 2018 Assignment instructions

More information

ENCM 335 Fall 2018 Lab 6 for the Week of October 22 Complete Instructions

ENCM 335 Fall 2018 Lab 6 for the Week of October 22 Complete Instructions page 1 of 5 ENCM 335 Fall 2018 Lab 6 for the Week of October 22 Complete Instructions Steve Norman Department of Electrical & Computer Engineering University of Calgary October 2018 Lab instructions and

More information

Slide Set 11. for ENCM 369 Winter 2015 Lecture Section 01. Steve Norman, PhD, PEng

Slide Set 11. for ENCM 369 Winter 2015 Lecture Section 01. Steve Norman, PhD, PEng Slide Set 11 for ENCM 369 Winter 2015 Lecture Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2015 ENCM 369 W15 Section

More information

Computer Programming: Skills & Concepts (CP) Variables and ints

Computer Programming: Skills & Concepts (CP) Variables and ints CP Lect 3 slide 1 25 September 2017 Computer Programming: Skills & Concepts (CP) Variables and ints C. Alexandru 25 September 2017 CP Lect 3 slide 2 25 September 2017 Week 1 Lectures Structure of the CP

More information

Welcome to... CS113: Introduction to C

Welcome to... CS113: Introduction to C Welcome to... CS113: Introduction to C Instructor: Erik Sherwood E-mail: wes28@cs.cornell.edu Course Website: http://www.cs.cornell.edu/courses/cs113/2005fa/ The website is linked to from the courses page

More information

Slide Set 14. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Slide Set 14. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary Slide Set 14 for ENCM 339 Fall 2016 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary November 2016 ENCM 339 Fall 2016 Slide Set 14 slide 2/35

More information

Slide Set 18. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng

Slide Set 18. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng Slide Set 18 for ENCM 339 Fall 2017 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary December 2017 ENCM 339 Fall 2017 Section 01

More information

Slide Set 5. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

Slide Set 5. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng Slide Set 5 for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary February 2018 ENCM 369 Winter 2018 Section

More information

Slide Set 18. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Slide Set 18. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary Slide Set 18 for ENCM 339 Fall 2016 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary December 2016 ENCM 339 Fall 2016 Slide Set 18 slide 2/26

More information

C Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

C Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee C Language Part 2 (Minor modifications by the instructor) 1 Scope Rules A variable declared inside a function is a local variable Each local variable in a function comes into existence when the function

More information

Outline. Computer programming. Debugging. What is it. Debugging. Hints. Debugging

Outline. Computer programming. Debugging. What is it. Debugging. Hints. Debugging Outline Computer programming Debugging Hints Gathering evidence Common C errors "Education is a progressive discovery of our own ignorance." Will Durant T.U. Cluj-Napoca - Computer Programming - lecture

More information

Pointers. Pointer Variables. Chapter 11. Pointer Variables. Pointer Variables. Pointer Variables. Declaring Pointer Variables

Pointers. Pointer Variables. Chapter 11. Pointer Variables. Pointer Variables. Pointer Variables. Declaring Pointer Variables Chapter 11 Pointers The first step in understanding pointers is visualizing what they represent at the machine level. In most modern computers, main memory is divided into bytes, with each byte capable

More information

Fundamentals of Programming Session 4

Fundamentals of Programming Session 4 Fundamentals of Programming Session 4 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2011 These slides are created using Deitel s slides, ( 1992-2010 by Pearson Education, Inc).

More information

CSE 374 Programming Concepts & Tools

CSE 374 Programming Concepts & Tools CSE 374 Programming Concepts & Tools Hal Perkins Fall 2017 Lecture 8 C: Miscellanea Control, Declarations, Preprocessor, printf/scanf 1 The story so far The low-level execution model of a process (one

More information

Slides for Lecture 15

Slides for Lecture 15 Slides for Lecture 15 ENCM 501: Principles of Computer Architecture Winter 2014 Term Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary 6 March,

More information

ENCM 501 Winter 2016 Assignment 1 for the Week of January 25

ENCM 501 Winter 2016 Assignment 1 for the Week of January 25 page 1 of 5 ENCM 501 Winter 2016 Assignment 1 for the Week of January 25 Steve Norman Department of Electrical & Computer Engineering University of Calgary January 2016 Assignment instructions and other

More information

Agenda. Peer Instruction Question 1. Peer Instruction Answer 1. Peer Instruction Question 2 6/22/2011

Agenda. Peer Instruction Question 1. Peer Instruction Answer 1. Peer Instruction Question 2 6/22/2011 CS 61C: Great Ideas in Computer Architecture (Machine Structures) Introduction to C (Part II) Instructors: Randy H. Katz David A. Patterson http://inst.eecs.berkeley.edu/~cs61c/sp11 Spring 2011 -- Lecture

More information

University of Calgary Department of Electrical and Computer Engineering ENCM 335 Instructor: Steve Norman

University of Calgary Department of Electrical and Computer Engineering ENCM 335 Instructor: Steve Norman page 1 of 6 University of Calgary Department of Electrical and Computer Engineering ENCM 335 Instructor: Steve Norman Fall 2018 MIDTERM TEST Thursday, November 1 6:30pm to 8:30pm Please do not write your

More information

University of Calgary Department of Electrical and Computer Engineering ENCM 339 Lecture Section 01 Instructor: Steve Norman

University of Calgary Department of Electrical and Computer Engineering ENCM 339 Lecture Section 01 Instructor: Steve Norman page 1 of 6 University of Calgary Department of Electrical and Computer Engineering ENCM 339 Lecture Section 01 Instructor: Steve Norman Fall 2017 MIDTERM TEST Wednesday, November 1 7:00pm to 9:00pm This

More information

The University of Calgary. ENCM 339 Programming Fundamentals Fall 2016

The University of Calgary. ENCM 339 Programming Fundamentals Fall 2016 The University of Calgary ENCM 339 Programming Fundamentals Fall 2016 Instructors: S. Norman, and M. Moussavi Wednesday, November 2 7:00 to 9:00 PM The First Letter of your Last Name:! Please Print your

More information

T02 Tutorial Slides for Week 2

T02 Tutorial Slides for Week 2 T02 Tutorial Slides for Week 2 ENEL 353: Digital Circuits Fall 2017 Term Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary 19 September, 2017

More information

ENCM 339 Fall 2017 Lecture Section 01 Lab 5 for the Week of October 16

ENCM 339 Fall 2017 Lecture Section 01 Lab 5 for the Week of October 16 page 1 of 5 ENCM 339 Fall 2017 Lecture Section 01 Lab 5 for the Week of October 16 Steve Norman Department of Electrical & Computer Engineering University of Calgary October 2017 Lab instructions and other

More information

Contents Slide Set 9. Final Notes on Textbook Chapter 7. Outline of Slide Set 9. More about skipped sections in Chapter 7. Outline of Slide Set 9

Contents Slide Set 9. Final Notes on Textbook Chapter 7. Outline of Slide Set 9. More about skipped sections in Chapter 7. Outline of Slide Set 9 slide 2/41 Contents Slide Set 9 for ENCM 369 Winter 2014 Lecture Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2014

More information

Slide Set 15 (Complete)

Slide Set 15 (Complete) Slide Set 15 (Complete) for ENCM 339 Fall 2017 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary November 2017 ENCM 339 Fall 2017

More information

Two s Complement Review. Two s Complement Review. Agenda. Agenda 6/21/2011

Two s Complement Review. Two s Complement Review. Agenda. Agenda 6/21/2011 Two s Complement Review CS 61C: Great Ideas in Computer Architecture (Machine Structures) Introduction to C (Part I) Instructor: Michael Greenbaum http://inst.eecs.berkeley.edu/~cs61c/su11 Suppose we had

More information

Slide Set 5. for ENCM 501 in Winter Term, Steve Norman, PhD, PEng

Slide Set 5. for ENCM 501 in Winter Term, Steve Norman, PhD, PEng Slide Set 5 for ENCM 501 in Winter Term, 2017 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2017 ENCM 501 W17 Lectures: Slide

More information

ENCM 339 Fall 2017 Lecture Section 01 Lab 9 for the Week of November 20

ENCM 339 Fall 2017 Lecture Section 01 Lab 9 for the Week of November 20 page 1 of 9 ENCM 339 Fall 2017 Lecture Section 01 Lab 9 for the Week of November 20 Steve Norman Department of Electrical & Computer Engineering University of Calgary November 2017 Lab instructions and

More information

Tutorial 5. Call Stack and Stack Frames. Memory Addresses and Pointers. Content vs Address of Pointers. scanf() function. Perils of Pointers

Tutorial 5. Call Stack and Stack Frames. Memory Addresses and Pointers. Content vs Address of Pointers. scanf() function. Perils of Pointers Tutorial 5 Call Stack and Stack Frames Memory Addresses and Pointers Content vs Address of Pointers scanf() function Perils of Pointers Function Pointers CS 136 Winter 2018 Tutorial 5 1 Call Stack and

More information

Chapter 7 Functions. Now consider a more advanced example:

Chapter 7 Functions. Now consider a more advanced example: Chapter 7 Functions 7.1 Chapter Overview Functions are logical groupings of code, a series of steps, that are given a name. Functions are especially useful when these series of steps will need to be done

More information

Lecture 12 CSE July Today we ll cover the things that you still don t know that you need to know in order to do the assignment.

Lecture 12 CSE July Today we ll cover the things that you still don t know that you need to know in order to do the assignment. Lecture 12 CSE 110 20 July 1992 Today we ll cover the things that you still don t know that you need to know in order to do the assignment. 1 The NULL Pointer For each pointer type, there is one special

More information

Formal Semantics. Prof. Clarkson Fall Today s music: Down to Earth by Peter Gabriel from the WALL-E soundtrack

Formal Semantics. Prof. Clarkson Fall Today s music: Down to Earth by Peter Gabriel from the WALL-E soundtrack Formal Semantics Prof. Clarkson Fall 2015 Today s music: Down to Earth by Peter Gabriel from the WALL-E soundtrack Review Previously in 3110: simple interpreter for expression language: abstract syntax

More information

Deep C (and C++) by Olve Maudal

Deep C (and C++) by Olve Maudal Deep C (and C++) by Olve Maudal http://www.noaanews.noaa.gov/stories2005/images/rov-hercules-titanic.jpg Programming is hard. Programming correct C and C++ is particularly hard. Indeed, it is uncommon

More information

Lecture 4 CSE July 1992

Lecture 4 CSE July 1992 Lecture 4 CSE 110 6 July 1992 1 More Operators C has many operators. Some of them, like +, are binary, which means that they require two operands, as in 4 + 5. Others are unary, which means they require

More information

CS113: Lecture 4. Topics: Functions. Function Activation Records

CS113: Lecture 4. Topics: Functions. Function Activation Records CS113: Lecture 4 Topics: Functions Function Activation Records 1 Why functions? Functions add no expressive power to the C language in a formal sense. Why have them? Breaking tasks into smaller ones make

More information

Slides for Lecture 15

Slides for Lecture 15 Slides for Lecture 5 ENEL 353: Digital Circuits Fall 203 Term Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary October, 203 ENEL 353 F3 Section

More information

CSCI 2132 Software Development. Lecture 17: Functions and Recursion

CSCI 2132 Software Development. Lecture 17: Functions and Recursion CSCI 2132 Software Development Lecture 17: Functions and Recursion Instructor: Vlado Keselj Faculty of Computer Science Dalhousie University 15-Oct-2018 (17) CSCI 2132 1 Previous Lecture Example: binary

More information

Slide Set 8. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

Slide Set 8. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng Slide Set 8 for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary March 2018 ENCM 369 Winter 2018 Section 01

More information

Computer Programming: Skills & Concepts (CP) arithmetic, if and booleans (cont)

Computer Programming: Skills & Concepts (CP) arithmetic, if and booleans (cont) CP Lect 5 slide 1 Monday 2 October 2017 Computer Programming: Skills & Concepts (CP) arithmetic, if and booleans (cont) Cristina Alexandru Monday 2 October 2017 Last Lecture Arithmetic Quadratic equation

More information

BSM540 Basics of C Language

BSM540 Basics of C Language BSM540 Basics of C Language Chapter 9: Functions I Prof. Manar Mohaisen Department of EEC Engineering Review of the Precedent Lecture Introduce the switch and goto statements Introduce the arrays in C

More information

CS 137 Part 2. Loops, Functions, Recursion, Arrays. September 22nd, 2017

CS 137 Part 2. Loops, Functions, Recursion, Arrays. September 22nd, 2017 CS 137 Part 2 Loops, Functions, Recursion, Arrays September 22nd, 2017 Loops We will finish this week with looping statements We already discussed one such structure, namely while loops. while (expr) statement

More information

COMP s1 Lecture 1

COMP s1 Lecture 1 COMP1511 18s1 Lecture 1 1 Numbers In, Numbers Out Andrew Bennett more printf variables scanf 2 Before we begin introduce yourself to the person sitting next to you why did

More information

ENCM 339 Fall 2017 Lecture Section 01 Lab 3 for the Week of October 2

ENCM 339 Fall 2017 Lecture Section 01 Lab 3 for the Week of October 2 page 1 of 11 ENCM 339 Fall 2017 Lecture Section 01 Lab 3 for the Week of October 2 Steve Norman Department of Electrical & Computer Engineering University of Calgary September 2017 Lab instructions and

More information

Goals of this Lecture

Goals of this Lecture C Pointers Goals of this Lecture Help you learn about: Pointers and application Pointer variables Operators & relation to arrays 2 Pointer Variables The first step in understanding pointers is visualizing

More information

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information Laboratory 2: Programming Basics and Variables Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information 3. Comment: a. name your program with extension.c b. use o option to specify

More information

ENCM 369 Winter 2019 Lab 6 for the Week of February 25

ENCM 369 Winter 2019 Lab 6 for the Week of February 25 page of ENCM 369 Winter 29 Lab 6 for the Week of February 25 Steve Norman Department of Electrical & Computer Engineering University of Calgary February 29 Lab instructions and other documents for ENCM

More information

Government Polytechnic Muzaffarpur.

Government Polytechnic Muzaffarpur. Government Polytechnic Muzaffarpur. Name of the Lab: COMPUTER PROGRAMMING LAB (MECH. ENGG. GROUP) Subject Code: 1625408 Experiment: 1 Aim: Programming exercise on executing a C program. If you are looking

More information

AN OVERVIEW OF C, PART 3. CSE 130: Introduction to Programming in C Stony Brook University

AN OVERVIEW OF C, PART 3. CSE 130: Introduction to Programming in C Stony Brook University AN OVERVIEW OF C, PART 3 CSE 130: Introduction to Programming in C Stony Brook University FANCIER OUTPUT FORMATTING Recall that you can insert a text field width value into a printf() format specifier:

More information

Slides for Lecture 6

Slides for Lecture 6 Slides for Lecture 6 ENCM 501: Principles of Computer Architecture Winter 2014 Term Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary 28 January,

More information

CpSc 1111 Lab 4 Formatting and Flow Control

CpSc 1111 Lab 4 Formatting and Flow Control CpSc 1111 Lab 4 Formatting and Flow Control Overview By the end of the lab, you will be able to: use fscanf() to accept a character input from the user and print out the ASCII decimal, octal, and hexadecimal

More information

Fundamentals of Programming & Procedural Programming

Fundamentals of Programming & Procedural Programming Universität Duisburg-Essen PRACTICAL TRAINING TO THE LECTURE Fundamentals of Programming & Procedural Programming Session Four: Functions: Built-in, Parameters and Arguments, Fruitful and Void Functions

More information

Sums. Here's a (poor) program to add three numbers

Sums. Here's a (poor) program to add three numbers Arrays 1 2 Sums 3 Here's a (poor) program to add three numbers /* Add three numbers */ #include add.c int main() { int numbers[3]; numbers[0] = 16; numbers[1] = 12; numbers[2] = 14; int sum =

More information

CpSc 1111 Lab 5 Formatting and Flow Control

CpSc 1111 Lab 5 Formatting and Flow Control CpSc 1111 Lab 5 Formatting and Flow Control Overview By the end of the lab, you will be able to: use fscanf() to accept a character input from the user execute a basic block iteratively using loops to

More information

Introduction: The Unix shell and C programming

Introduction: The Unix shell and C programming Introduction: The Unix shell and C programming 1DT048: Programming for Beginners Uppsala University June 11, 2014 You ll be working with the assignments in the Unix labs. If you are new to Unix or working

More information

ENCM 369 Winter 2015 Lab 6 for the Week of March 2

ENCM 369 Winter 2015 Lab 6 for the Week of March 2 page of 2 ENCM 369 Winter 25 Lab 6 for the Week of March 2 Steve Norman Department of Electrical & Computer Engineering University of Calgary February 25 Lab instructions and other documents for ENCM 369

More information

Fundamentals of Programming. Lecture 3: Introduction to C Programming

Fundamentals of Programming. Lecture 3: Introduction to C Programming Fundamentals of Programming Lecture 3: Introduction to C Programming Instructor: Fatemeh Zamani f_zamani@ce.sharif.edu Sharif University of Technology Computer Engineering Department Outline A Simple C

More information

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

CMSC 201 Fall 2016 Lab 09 Advanced Debugging CMSC 201 Fall 2016 Lab 09 Advanced Debugging Assignment: Lab 09 Advanced Debugging Due Date: During discussion Value: 10 points Part 1: Introduction to Errors Throughout this semester, we have been working

More information

COSC 2P95. Procedural Abstraction. Week 3. Brock University. Brock University (Week 3) Procedural Abstraction 1 / 26

COSC 2P95. Procedural Abstraction. Week 3. Brock University. Brock University (Week 3) Procedural Abstraction 1 / 26 COSC 2P95 Procedural Abstraction Week 3 Brock University Brock University (Week 3) Procedural Abstraction 1 / 26 Procedural Abstraction We ve already discussed how to arrange complex sets of actions (e.g.

More information

CSE 374 Programming Concepts & Tools. Hal Perkins Fall 2015 Lecture 19 Introduction to C++

CSE 374 Programming Concepts & Tools. Hal Perkins Fall 2015 Lecture 19 Introduction to C++ CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 19 Introduction to C++ C++ C++ is an enormous language: All of C Classes and objects (kind of like Java, some crucial differences) Many

More information

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor CS 261 Fall 2017 Mike Lam, Professor C Introduction Variables, Memory Model, Pointers, and Debugging The C Language Systems language originally developed for Unix Imperative, compiled language with static

More information

BLM2031 Structured Programming. Zeyneb KURT

BLM2031 Structured Programming. Zeyneb KURT BLM2031 Structured Programming Zeyneb KURT 1 Contact Contact info office : D-219 e-mail zeynebkurt@gmail.com, zeyneb@ce.yildiz.edu.tr When to contact e-mail first, take an appointment What to expect help

More information

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d)

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d) CMSC 330: Organization of Programming Languages Tail Calls A tail call is a function call that is the last thing a function does before it returns let add x y = x + y let f z = add z z (* tail call *)

More information

Functions! Objectives! 1E3! Topic 9! programming! n This topic should allow students to! n Read chapter 6 of the textbook now.!

Functions! Objectives! 1E3! Topic 9! programming! n This topic should allow students to! n Read chapter 6 of the textbook now.! Functions 1E3 Topic 9 9 Functions 1 Objectives n This topic should allow students to n Understand the importance of abstraction in programming n Recognise when a function would be useful. n Design appropriate

More information

printf( Please enter another number: ); scanf( %d, &num2);

printf( Please enter another number: ); scanf( %d, &num2); CIT 593 Intro to Computer Systems Lecture #13 (11/1/12) Now that we've looked at how an assembly language program runs on a computer, we're ready to move up a level and start working with more powerful

More information

Deep C by Olve Maudal

Deep C by Olve Maudal Deep C by Olve Maudal http://www.noaanews.noaa.gov/stories2005/images/rov-hercules-titanic.jpg Programming is hard. Programming correct C is particularly hard. Indeed, it is uncommon to see a screenful

More information

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017 Control Structures Lecture 4 COP 3014 Fall 2017 September 18, 2017 Control Flow Control flow refers to the specification of the order in which the individual statements, instructions or function calls

More information

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are

More information

Fundamentals of Programming Session 15

Fundamentals of Programming Session 15 Fundamentals of Programming Session 15 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2013 These slides have been created using Deitel s slides Sharif University of Technology Outlines

More information

UNIVERSITY OF WINDSOR Winter 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated : Feb 7 th, Student Name: Student Number:

UNIVERSITY OF WINDSOR Winter 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated : Feb 7 th, Student Name: Student Number: UNIVERSITY OF WINDSOR 60-106-01 Winter 2007 QUIZ # 1 Solution Examiner:Ritu Chaturvedi Dated : Feb 7 th, 2007. Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) No calculators allowed.

More information

ENCM511 Assignment 1 Version 16 September 2012

ENCM511 Assignment 1 Version 16 September 2012 ENCM511 Assignment 1 Version 16 September 2012 This is an individual assignment, essentially a take home quiz. This means the purpose behind this assignment is for YOU to show the skills learnt during

More information

APS105. Modularity. C pre-defined functions 11/5/2013. Functions. Functions (and Pointers) main. Modularity. Math functions. Benefits of modularity:

APS105. Modularity. C pre-defined functions 11/5/2013. Functions. Functions (and Pointers) main. Modularity. Math functions. Benefits of modularity: APS105 Functions (and Pointers) Functions Tetbook Chapter5 1 2 Modularity Modularity Break a program into manageable parts (modules) Modules interoperate with each other Benefits of modularity: Divide-and-conquer:

More information

ENCM 501 Winter 2017 Assignment 3 for the Week of January 30

ENCM 501 Winter 2017 Assignment 3 for the Week of January 30 page 1 of 7 ENCM 501 Winter 2017 Assignment 3 for the Week of January 30 Steve Norman Department of Electrical & Computer Engineering University of Calgary January 2017 Assignment instructions and other

More information

CSE 5A Introduction to Programming I (C) Homework 4

CSE 5A Introduction to Programming I (C) Homework 4 CSE 5A Introduction to Programming I (C) Homework 4 Read Chapter 7 Due: Friday, October 26 by 6:00pm All programming assignments must be done INDIVIDUALLY by all members of the class. Start early to ensure

More information

Slide Set 5. for ENEL 353 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Slide Set 5. for ENEL 353 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary Slide Set 5 for ENEL 353 Fall 207 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Fall Term, 207 SN s ENEL 353 Fall 207 Slide Set 5 slide

More information