Topics discussed in this section:

Slides:



Advertisements
Similar presentations
More on Algorithms and Problem Solving
Advertisements

 Control structures  Algorithm & flowchart  If statements  While statements.
Computer Science: A Structured Programming Approach Using C1 6-7 Other Statements Related to Looping Three other C statements are related to loops: break,
Computer Science: A Structured Programming Approach Using C Converting File Type A rather common but somewhat trivial problem is to convert a text.
CS 240: Data Structures Binary Representations. Binary Binary is a numerical system that is used to represent numeric values. Binary is a numerical system.
CS150 Introduction to Computer Science 1
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand basic loop concepts: ■ pretest loops and post-test loops ■ loop.
 2003 Prentice Hall, Inc. All rights reserved. 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the basic concepts and uses of arrays ❏ To be able to define C.
Computer Science: A Structured Programming Approach Using C1 3-7 Sample Programs This section contains several programs that you should study for programming.
Computer Science: A Structured Programming Approach Using C Masks In many programs, bits are used as binary flags: 0 is off, and 1 is on. To set.
Computer Science: A Structured Programming Approach Using C1 8-5 Sorting One of the most common applications in computer science is sorting—the process.
Computer Science: A Structured Programming Approach Using C A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,
Computer Science: A Structured Programming Approach Using C1 6-9 Recursion In general, programmers use two approaches to writing repetitive algorithms.
Textbook Problem Java – An Introduction to Problem Solving & Programming, Walter Savitch, pp.219, Problem 08.
NUMBER SYSTEM Decimal System Binary System. We use two digits in this system (0,1) just like the existing system of computers.. And write the number in.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To be able to list and describe the six expression categories ❏ To understand.
Converting From decimal to Binary & Hexadecimal to Binary
Computer Science Department LOOPS. Computer Science Department Loops Loops Cause a section of your program to be repeated a certain number of times. The.
1 Objectives ❏ To understand basic loop concepts: ■ pretest loops and post-test loops ■ loop initialization and updating ■ event and counter controlled.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 4 - Control Structures: Part 1.
 2003 Prentice Hall, Inc. All rights reserved. 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection.
AP Computer Science A – Healdsburg High School 1 Unit 1 - Binary Numbers - Hexadecimal Numbers.
1 Lecture 3 Control Structures else/if and while.
1-Dec-15 Additional control structures. 2 The if-else statement The if-else statement chooses which of two statements to execute The if-else statement.
Chapter 7 Section 7.2 Addition & Subtraction in Different Bases.
Iteration Hussein Suleman UCT Dept of Computer Science CS115 ~ 2004.
COMPUTER SCIENCE Data Representation and Machine Concepts Section 1.5 Instructor: Lin Chen Sept 2013.
Computer Science: A Structured Programming Approach Using C1 6-6 Loop Examples This section contains several short examples of loop applications. Each.
 2003 Prentice Hall, Inc. All rights reserved. 1 Will not cover 4.14, Thinking About Objects: Identifying Class Attributes Chapter 4 - Control Structures.
Starter – Its the small things in life What’s wrong with this code Height = 10 Width = 10 A = Height * Width Print A Remember to check: Spelling Spacing.
Computer Science 4 On and OFF. Homework What have we created.
Computer Science: A Structured Programming Approach Using C1 5-5 Incremental Development Part II In Chapter 4, we introduced the concept of incremental.
Computer Programming 12 Lesson 6 – Loop structure By: Dan Lunney.
Binary Numbers Practice.
UCT Department of Computer Science Computer Science 1015F Iteration
Number Systems Decimal Can you write 12,045 in expanded form? Base? Allowable digits for each place?
Algorithm: procedure in terms of
Number Systems Write the decimal value of the binary number
INTRODUCTION TO PROBLEM SOLVING
COMPUTER ORGANIZATION
Selection—Making Decisions
FIGURE 4-10 Function Return Statements
CHAPTER 5A Loop Structure
Solve more difficult number problems mentally
COUNTING IN BINARY Binary weightings 0 x x x x 8
Topics discussed in this section:
Chapter 9 Pointers Objectives
Topics discussed in this section:
Topics discussed in this section:
Binary Files.
Chapter 6 Repetition Objectives ❏ To understand basic loop concepts:
3-7 Sample Programs This section contains several programs that you should study for programming technique and style. Computer Science: A Structured.
Structure of a C Program
Topics discussed in this section:
More Nested Loops and Lab 5
Number Systems Base 2, 10, 16.
3-3 Side Effects A side effect is an action that results from the evaluation of an expression. For example, in an assignment, C first evaluates the expression.
Chapter 8 Arrays Objectives
3-3 Side Effects A side effect is an action that results from the evaluation of an expression. For example, in an assignment, C first evaluates the expression.
Topics discussed in this section:
Topics discussed in this section:
Section 5.3A: Similar Triangles
Examples Example Problems, their Algorithms, and their C Source Code.
COUNTING IN BINARY Binary weightings 0 x x x x 8
Topics discussed in this section:
Chapter 8 Arrays Objectives
Chapter 4 - Control Structures: Part 1
Print the following triangle, using nested loops
Topics discussed in this section:
Presentation transcript:

Topics discussed in this section: 6-6 Loop Examples This section contains several short examples of loop applications. Each program demonstrates one or more programming concepts that you will find helpful in solving other problems. Topics discussed in this section: for Loops while LOOPS do…while LOOPS Computer Science: A Structured Programming Approach Using C

PROGRAM 6-9 Compound Interest Computer Science: A Structured Programming Approach Using C

PROGRAM 6-9 Compound Interest Computer Science: A Structured Programming Approach Using C

PROGRAM 6-9 Compound Interest Computer Science: A Structured Programming Approach Using C

FIGURE 6-18 Print Right Triangle Flowchart and Pseudocode Computer Science: A Structured Programming Approach Using C

Print Right Triangle Using Nested for PROGRAM 6-10 Print Right Triangle Using Nested for Computer Science: A Structured Programming Approach Using C

Print Right Triangle Using Nested for PROGRAM 6-10 Print Right Triangle Using Nested for Computer Science: A Structured Programming Approach Using C

Print Number Series Using User-specified Limit PROGRAM 6-11 Print Number Series Using User-specified Limit Computer Science: A Structured Programming Approach Using C

Print Number Series Using User-specified Limit PROGRAM 6-11 Print Number Series Using User-specified Limit Computer Science: A Structured Programming Approach Using C

PROGRAM 6-12 Print Calendar Month Computer Science: A Structured Programming Approach Using C

PROGRAM 6-12 Print Calendar Month Computer Science: A Structured Programming Approach Using C

PROGRAM 6-12 Print Calendar Month Computer Science: A Structured Programming Approach Using C

Never use one variable to control two processes. Note Never use one variable to control two processes. Computer Science: A Structured Programming Approach Using C

PROGRAM 6-13 Print Sum of Digits Computer Science: A Structured Programming Approach Using C

PROGRAM 6-13 Print Sum of Digits Computer Science: A Structured Programming Approach Using C

PROGRAM 6-14 Print Number Backward Computer Science: A Structured Programming Approach Using C

PROGRAM 6-14 Print Number Backward Computer Science: A Structured Programming Approach Using C

FIGURE 6-19 Design for Binary to Decimal Computer Science: A Structured Programming Approach Using C

Convert Binary to Decimal PROGRAM 6-15 Convert Binary to Decimal Computer Science: A Structured Programming Approach Using C

Convert Binary to Decimal PROGRAM 6-15 Convert Binary to Decimal Computer Science: A Structured Programming Approach Using C

Convert Binary to Decimal PROGRAM 6-15 Convert Binary to Decimal Computer Science: A Structured Programming Approach Using C

Convert Binary to Decimal PROGRAM 6-15 Convert Binary to Decimal Computer Science: A Structured Programming Approach Using C

Convert Binary to Decimal PROGRAM 6-15 Convert Binary to Decimal Computer Science: A Structured Programming Approach Using C

Convert Binary to Decimal PROGRAM 6-15 Convert Binary to Decimal Computer Science: A Structured Programming Approach Using C

Convert Binary to Decimal PROGRAM 6-15 Convert Binary to Decimal Computer Science: A Structured Programming Approach Using C