C language - Lecture 4 Page 1 BIL 104E INTRODUCTION TO...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Compiled by Ergin TARI Lecture 4, Page 1 BIL 104E INTRODUCTION TO SCIENTIFIC AND ENGINEERING COMPUTING
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Compiled by Ergin TARI Lecture 4, Page 2 INFORMATION TO USERS THE NOTES IN THE FOLLOWING SLIDES ARE COMPILED FROM FREE VERSIONS OF THE BOOKS Sams Teach Yourself C in 21 Days (Sams Teach Yourself) By Peter Aitken and Sams Teach Yourself C in 24 Hours ( Published by Sams ) By Tony Zhang. The electronic versions of these and other books can be found in the web pages including http://server11.hypermart.net/davidbook901/data/c/c1f8c0d9.htm http://www.informit.com/itlibrary http://www.free-book.co.uk/computers-internet/programming/c/ http://aelinik.free.fr/c/
Background image of page 2
Compiled by Ergin TARI Lecture 4, Page 3 BIL104E: Introduction to Scientific and Engineering Computing, Summer 2007 Week 4 Outline Algorithms Pseudocode Control Structures Decision Making: Equality and Relational Operators The if Selection Structure The if/else Selection Structure Nested control structures Switch-Case (and break) More on Operators Logical Operators Conditional Operator
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Compiled by Ergin TARI Lecture 4, Page 4 Introduction • Before writing a program: – Have a thorough understanding of the problem – Carefully plan an approach for solving it • While writing a program: – Know what “building blocks” are available – Use good programming principles
Background image of page 4
Compiled by Ergin TARI Lecture 4, Page 5 Algorithms • Computing problems – All can be solved by executing a series of actions in a specific order • Algorithm: procedure in terms of – Actions to be executed – The order in which these actions are to be executed • Program control – Specify order in which statements are to executed
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Compiled by Ergin TARI Lecture 4, Page 6 Pseudocode • Pseudocode – Artificial, informal language that helps us develop algorithms – Similar to everyday English – Not actually executed on computers – Helps us “think out” a program before writing it • Easy to convert into a corresponding C program • Consists only of executable statements
Background image of page 6
Compiled by Ergin TARI Lecture 4, Page 7 – Pseudocode for a nested if / else structure If student’s grade is greater than or equal to 90 Print “A” else If student’s grade is greater than or equal to 80 Print “B” else If student’s grade is greater than or equal to 70 Print “C” else If student’s grade is greater than or equal to 60 Print “D” else Print “F” Pseudocode
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Compiled by Ergin TARI Lecture 4, Page 8 Control Structures • Sequential execution – Statements executed one after the other in the order written • Transfer of control – When the next statement executed is not the next one in sequence • Bohm and Jacopini – All programs written in terms of 3 control structures • Sequence structures: Built into C. Programs executed sequentially by default • Selection structures: C has three types: if , if / else , and switch ( this week’s mater ial) • Repetition structures: C has three types: while , do / while and for ( next week’s material )
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/22/2010 for the course CSE 104 taught by Professor E.t. during the Spring '09 term at Istanbul Technical University.

Page1 / 55

C language - Lecture 4 Page 1 BIL 104E INTRODUCTION TO...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online