CSE 101 Lesson - 1 Number System & Program Design Sonia corraya (SOC)

Slides:



Advertisements
Similar presentations
Transforming Data into Information lesson 7 This lesson includes the following sections: How Computers Represent Data How Computers Process Data Factors.
Advertisements

Number Systems and Codes
SECTION 4a Transforming Data into Information.
Flow chart and Algorithm. Announcement Exam One – Wednesday October 1st – 100 points – Mixture of short answer, problem solving, matching, and maybe a.
Flow Control Analysis & Design Tool: Flowcharts
UNIT 2. Introduction to Computer Programming
CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Subject: Information Technology Grade: 10
Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:
ITEC113 Algorithms and Programming Techniques
Digital Fundamentals Floyd Chapter 2 Tenth Edition
An Overview of Programming Logic and Design
Data Representation in Computers
The Program Design Phases
Review Algorithm Analysis Problem Solving Space Complexity
Digital Logic Chapter 2 Number Conversions Digital Systems by Tocci.
ALGORITHMS AND FLOWCHARTS
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
Programmable Logic Controllers
Numbering systems.
Introduction to Programming Lecture Number:. What is Programming Programming is to instruct the computer on what it has to do in a language that the computer.
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
Transforming Data into Information.
Comp Sci 251 Intro 1 Computer organization and assembly language Wing Huen.
EX_01.1/46 Numeric Systems. EX_01.2/46 Overview Numeric systems – general, Binary numbers, Octal numbers, Hexadecimal system, Data units, ASCII code,
Number Systems Spring Semester 2013Programming and Data Structure1.
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
Number systems: binary, decimal, hexadecimal and octal. Conversion between various number systems Number systems: binary, decimal, hexadecimal and octal.
Number Systems and Codes. CS2100 Number Systems and Codes 2 NUMBER SYSTEMS & CODES Information Representations Number Systems Base Conversion Negative.
Computer Systems Architecture Copyright © Genetic Computer School 2008 CSA 1- 0 Lesson 1 Number System.
S2008Final_part1.ppt CS11 Introduction to Programming Final Exam Part 1 S A computer is a mechanical or electrical device which stores, retrieves,
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
Number systems, Operations, and Codes
INTRODUCTION TO COMPUTING CHAPTER NO. 04. Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols.
Flowcharts.
Flowcharts and Algorithms. Review of Terms  A computer is a machine that can represent and manipulate data –Ultimately the data and the instructions.
ITEC113 Algorithms and Programming Techniques
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
Data Representation, Number Systems and Base Conversions
Programming in C++ Dale/Weems/Headington Chapter 1 Overview of Programming and Problem Solving.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
MECH1500 Chapter 3.
Computer Number System
Chapter 1 Number Systems Digital Electronics. Topics discussed in last lecture Digital systems Advantages of using digital signals over analog. Disadvantages.
09/06/ Data Representation ASCII, Binary Denary Conversion, Integer & Boolean data types.
Fall’ 2014 Lesson - 1 Number System & Program Design CSE 101.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
Digital System Design. Objective Distinguish between Two worlds Understand the Properties digital system.
CSE 110: Programming Language I Matin Saad Abdullah UB 404.
CHAPTER 3 BINARY NUMBER SYSTEM. Computers are electronic machines which operate using binary logic. These devices use two different values to represent.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Fall’ 2014 Number System CSE Number System How Computers Represent Data Binary Numbers The Binary Number System Bits and Bytes Text Codes Binary.
EEE 301 : Digital ELECTRONICS Amina Hasan Abedin Senior lecturer, Dept of EEE, BRAC University.
CSE 260 Digital Logic Design Md. Shamsul Kaonain Khadija Rasul Aniqua Zereen.
1. Binary, Decimal, Hexadecimal and Octal. 2. Conversion between various number systems. Number Systems:
(Courtesy: Dr. Amitabha Chakrabarty) Lesson - 2 Number System & Program Design CSE 101.
Programming and Data Structure
Number Systems and Codes
NUMBER SYSTEMS.
Number Representation
Digital Electronics INTRODUCTION ANALOG VS DIGITAL NUMBER SYSTEMS.
Number System conversions
ALGORITHMS AND FLOWCHARTS
Unit# 9: Computer Program Development
Number Systems and Codes
Numbering System TODAY AND TOMORROW 11th Edition
ALGORITHMS AND FLOWCHARTS
Chapter Four Data Representation in Computers By Bezawit E.
Transforming Data into Information
Presentation transcript:

CSE 101 Lesson - 1 Number System & Program Design Sonia corraya (SOC)   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh Sonia corraya (SOC)

This Lesson Includes Following section Number System Program Design & Algorithm Flow Chart   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh

Number System How Computers Represent Data Binary Numbers The Binary Number System Bits and Bytes Text Codes Binary Number Computer processing is performed by transistors, which are switches with only two possible states: on and off. All computer data is converted to a series of binary numbers– 1 and 0. For example, you see a sentence as a collection of letters, but the computer sees each letter as a collection of 1s and 0s. If a transistor is assigned a value of 1, it is on. If it has a value of 0, it is off. A computer's transistors can be switched on and off millions of times each second.   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh

Number System The Binary Number System 0 (00) 1 (01) 2 (10) 3 (11) To convert data into strings of numbers, computers use the binary number system. Humans use the decimal system (“deci” stands for “ten”). Elementory storage units inside computer are electronic switches. Each switch holds one of two states: on (1) or off (0). We use a bit (binary digit), 0 or 1, to represent the state. ON OFF The binary number system works the same way as the decimal system, but has only two available symbols (0 and 1) rather than ten (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9). 0 (00) 1 (01) 2 (10) 3 (11)   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh

Number System Bits and Bytes A single unit of data is called a bit, having a value of 1 or 0. Computers work with collections of bits, grouping them to represent larger pieces of data, such as letters of the alphabet. Eight bits make up one byte. A byte is the amount of memory needed to store one alphanumeric character. With one byte, the computer can represent one of 256 different symbols or characters.   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh 1 0 1 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 0 1 0 1 0 0 1 0 0 1 1

Number System Text Codes A text code is a system that uses binary numbers (1s and 0s) to represent characters understood by humans (letters and numerals). An early text code system, called EBCDIC (Extended Binary Coded Decimal Interchange Code), uses eight-bit codes, but is used primarily in older mainframe systems. In the most common text-code set, ASCII (American Standard Code for Information Interchange), each character consists of eight bits (one byte) of data. ASCII is used in nearly all personal computers. In the Unicode text-code set, each character consists of 16 bits (two bytes) of data Code Character 00110000 00110001 1 00110010 2 00110011 3 00110100 4 00110101 5 01000001 A 01000010 B 01000011 C 01000100 D 01000101 E   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh

Number System In general, N bits can represent 2N different values. For M values, bits are needed. 1 bit  represents up to 2 values (0 or 1) 2 bits  rep. up to 4 values (00, 01, 10 or 11) 3 bits  rep. up to 8 values (000, 001, 010. …, 110, 111) 4 bits  rep. up to 16 values (0000, 0001, 0010, …, 1111) 32 values  requires 5 bits 64 values  requires 6 bits 1024 values  requires 10 bits 40 values  requires 6 bits 100 values  requires 7 bits Decimal number system, symbols = { 0, 1, 2, 3, …, 9 } Position is important Example:(7594)10 = (7x103) + (5x102) + (9x101) + (4x100) In general, (anan-1… a0)10 = (an x 10n) + (an-1 x 10n-1) + … + (a0 x 100) (2.75)10 = (2 x 100) + (7 x 10-1) + (5 x 10-2) In general, (anan-1… a0 . f1f2 … fm)10 = (an x 10n) + (an-1x10n-1) + … + (a0 x 100) + (f1 x 10-1) + (f2 x 10-2) + … + (fm x 10-m)   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh

Other Number System Binary (base 2): weights in powers-of-2. Binary digits (bits): 0,1. Octal (base 8): weights in powers-of-8. Octal digits: 0,1,2,3,4,5,6,7 Hexadecimal (base 16): weights in powers-of-16. Hexadecimal digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F Binary Octal Decimal Hexadecimal 0000 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 10 8 1001 11 9 1010 12 A 1011 13 B 1100 14 C 1101 15 D 1110 16 E 1111 17 F   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh

Number System – Base–R to Decimal Conversion (1101.101)2 = 123 + 122 + 120 + 12-1 + 02-2 12-3 = 8 + 4 + 1 + 0.5 + 0.125 = (13.625)10 (572.6)8 = 582 + 781 + 280 + 68-1 = 320 + 56 + 2 + 0.75 = (378.75)10 (2A.8)16 = 2161 + 10160 + 816-1 = 32 + 10 + 0.5 = (42.5)10 (341.24)5 = 352 + 451 + 150 + 25-1 + 45-2 = 75 + 20 + 1 + 0.4 + 0.16 = (96.56)10   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh

Number System – Decimal to Binary Conversion Method 1: Sum-of-Weights Method Method 2: Repeated Division-by-2 Method (for whole numbers) Repeated Multiplication-by-2 Method (for fractions) Sum-of-Weights Method Determine the set of binary weights whose sum is equal to the decimal number. (9)10 = 8 + 1 = 23 + 20 = (1001)2 (18)10 = 16 + 2 = 24 + 21 = (10010)2 (58)10 = 32 + 16 + 8 + 2 = 25 + 24 + 23 + 21 = (111010)2 (0.625)10 = 0.5 + 0.125 = 2-1 + 2-3 = (0.101)2   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh

Number System – Decimal to Binary Conversion Repeated Division-by-2 Method (for whole number) To convert a whole number to binary, use successive division by 2 until the quotient is 0. The remainders form the answer, with the first remainder as the least significant bit (LSB) and the last as the most significant bit (MSB). (43)10 = (101011)2 Repeated Multiplication-by-2 Method (for fractions) To convert decimal fractions to binary, repeated multiplication by 2 is used, until the fractional product is 0 (or until the desired number of decimal places). The carried digits, or carries, produce the answer, with the first carry as the MSB, and the last as the LSB. (0.3125)10 = (.0101)2   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh

Number System - Conversion between Decimal to other Base Decimal to base-R whole numbers: repeated division-by-R fractions: repeated multiplication-by-R In general, conversion between bases can be done via decimal: Base-2 Base-2 Base-3 Base-3 Base-4 Decimal Base-4 … …. Base-R Base-R   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh

Number System - Conversion between Decimal to other Base Octal and Hexadecimal Numbers The conversion of binary, octal and hexadecimal plays an important part in digital computers. Each octal digit corresponds to three digits and each hexadecimal digit corresponds to four binary digits. The conversion from binary to octal is easily accomplished by partitioning the binary number into groups of three each, starting from the binary point and proceeding to the left and to the right. Conversion from binary to hxadecimal is similar. Conversion from the octal or hexadecimal to binary is done by procedure reverse to the above. Binary-Octal/Hexadecimal Conversion Binary  Octal: Partition in groups of 3 (10 111 011 001 . 101 110)2 = (2731.56)8 Octal  Binary: reverse (2731.56)8 = (10 111 011 001 . 101 110)2 Binary  Hexadecimal: Partition in groups of 4 (101 1101 1001 . 1011 1000)2 = (5D9.B8)16 Hexadecimal  Binary: reverse (5D9.B8)16 = (101 1101 1001 . 1011 1000)2   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh

Program Design What is a computer program? Simply put, a computer program is a set of detailed directions telling the computer exactly what to do, one step at a time. A program can be as short as one line of code, or as long as several millions lines of code. Typically, a program is stored as a collection of files. Some common file types used in programs are: Executable (.EXE) files actually send commands to the processor. Dynamic Link Library (.DLL) files are partial .EXE files. Initialization (.INI) files contain configuration information for a program. Help (.HLP) files contain information for the user.   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh

Program Design The Evolution of Programming Languages To build programs, people use languages that are similar to human language. The results are translated into machine code, which computers understand Programming has changed a lot since the first computers were created. They can be categorized based on how close to normal speech they are, and thus how far from the computer's internal language. 1st GL Machine Language (1945) 2nd GL Assembly Language (1950) 3rd GL High Level Language (1960) 4th GL Very High Level Language (1970) 5th GL Natural Language (1980) Language Types Programming has changed a lot since the first computers were created. The original programs were very simple and straight forward compared to today's elaborate databases, word processors, schedulers, and action games. Different computer languages have been created with which to write these increasingly complex computer programs. They can be categorized based on how close to normal speech they are, and thus how far from the computer's internal language. Machine Languages The language of the CPU (The central processing unit of the computer, which is the part that does the "thinking"). The lowest level language. Composed of 0's and 1's . So Machine code or machine language is a system of instructions and data executed directly by a computer's central processing unit. Machine code may be regarded as a primitive (and cumbersome) programming language or as the lowest-level representation of a compiled and/or assembled computer program. Machine languages (first-generation languages) are the most basic type of computer languages, consisting of strings of numbers the computer's hardware can use. Different types of hardware use different machine code. For example, IBM computers use different machine language than Apple computers. Assembly Languages A much more readable rendition of machine language, called assembly language, uses mnemonic codes to refer to machine code instructions, rather than simply using the instructions' numeric values. Assembly languages (second-generation languages) are only somewhat easier to work with than machine languages. To create programs in assembly language, developers use cryptic English-like phrases to represent strings of numbers. The code is then translated into object code, using a translator called an assembler. For example, on the Zilog Z80 processor, the machine code 00000101, which causes the CPU to decrement the B processor register, would be represented in assembly language as DEC B. High-Level Languages Use program statements - words and algebra-type expressions. Developed in the 50's and 60's. After a program is written in one of the high-level languages, it must be either compiled or interpreted. A compiler program rewrites the program into machine language that the CPU can understand. This is done all at once and the program is saved in this new form. A compiled program is generally considerably larger than the original. An interpreter program translates the program statements into machine language one line at a time as the program is running. An interpreted program will be smaller than a compiled one but will take longer to execute. Higher-level languages are more powerful than assembly language and allow the programmer to work in a more English-like environment. Higher-level programming languages are divided into three "generations," each more powerful than the last: Third-generation languages Fourth-generation languages Fifth-generation languages 3rd Generation Language Third-generation languages (3GLs) are the first to use true English-like phrasing, making them easier to use than previous languages. 3GLs are portable, meaning the object code created for one type of system can be translated for use on a different type of system. The following languages are 3GLs: FORTAN C COBOL C++ BASIC Java Pascal ActiveX 4th Generation Languages = 4GL. Very high-level languages. These are results oriented and include database query languages. There are fewer options for programmers, but the programs are much easier to write than in lower level languages. These too must be compiled or interpreted. Fourth-generation languages (4GLs) are even easier to use than 3GLs. 4GLs may use a text-based environment (like a 3GL) or may allow the programmer to work in a visual environment, using graphical tools. The following languages are 4GLs: Visual Basic (VB) VisualAge Authoring environments Natural Languages   5th Generation Languages. We don't really have any programming languages yet that use natural language. In such a language you would write statements that look like normal sentences. For example, instead of odd-looking code you would write "Who are the salesmen with sales over $20,000 last month?" Fifth-generation languages (5GLs) are an issue of debate in the programming community – some programmers cannot agree that they even exist. These high-level languages would use artificial intelligence to create software, making 5GLs extremely difficult to develop   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh

Program Design - Algorithm An algorithm is a sequence of finite instructions, often used for calculation and data processing. Start with a real-world problem that needs to be solved. Convert the real-world problem into a computational problem Develop an algorithm and use it to solve the computational problem An algorithm is a precise list of instructions that determine what operations to perform on what pieces of data, in what order. Lets see How to cook (make cake) ?   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh

Program Design - Pseudocode Generic way of describing an algorithm, without use of any specific programming language. It Helps programmers to plan an algorithm. This is not an actual programming language, but may borrow syntax from popular programming languages. Example Problem: Calculate the bill when someone buys a specific number of some item: Pseudocode: PROMT for number of items being purchased READ number of items being purchased PROMPT for price per item READ price per item CALCULATE subtotal CALCULATE tax CALCULATE total DISPLAY total When describing input, output, computations, etc, the following terms are often used: Input: INPUT, READ, GET Output: PRINT, DISPLAY, SHOW, PROMPT Compute: COMPUTE, CALCULATE, DETERMINE Initialize: SET, INIT Add one: INCREMENT, BUMP Decisions: TEST, IF/THEN/ELSE, WHILE/DO   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh

Program Design - Pseudocode Example Problem: Calculate two childrens’ allowances, based upon 75 cents per year old. Known Values Rate = 75 cents per year Inputs Ages of children Calculations Allowance = Age x Rate Outputs Allowances for each child Pseudo Code Algorithm: PROMPT for Age of Child1 READ Age of Child1 PROMPT for Age of Child2 READ Age of Child2 CALCULATE Allowance for Child1 = Age of Child1 x Rate CALCULATE Allowance for Child2 = Age of Child2 x Rate DISPLAY Allowance for Child1 DISPLAY Allowance for Child2   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh

Program Design - Pseudocode Sequential: With sequential program statements, you execute one statement after another (like steps in a list) After step X is completed, step X+1 will be performed, until the last statement has been executed. Every step in the list will be performed. Each step in the list will be performed once and only once.   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh

Program Design - Pseudocode Non - Sequential: Programs that execute only sequential program statements are pretty simplistic. Most programs need more flexibility in the order of statement execution. The order of statement execution is called the flow of control. Control statements allow the execution of statements based upon decisions.   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh

Program Design - Pseudocode Conditional statements: Decide whether or not to execute a particular statement or statements Also called the selection statements or decision statements. Pseudo code Example: IF Hours Worked over 40 THEN DISPLAY overtime pay ELSE DISPLAY regular pay Loop statements: Repeatedly execute the same statement(s) for a certain number of times or until a test condition is satisfied. Pseudo code Example: WHILE Population UNDER Limit DO COMPUTE Population = Population + Births – Deaths Conditional statements: Also called the selection statements or decision statements. Decide whether or not to execute a particular statement or statements Pseudocode Example: ELSE DISPLAY regular pay THEN DISPLAY overtime pay IF HoursWorked over 40 Real World Problem: Calculate one child’s allowance, based upon 75 cents per year old if s/he is under 10, and $1 per year if 10 or over. Known Values BreakAge = 10 OlderRate = 100 cents per year YoungRate = 75 cents per year Inputs Calculations Age of child Allowance Outputs Allowance = Age x Rate Pseudocode Algorithm: READ Age PROMPT for Age THEN CALCULATE Allowance = Age x YoungRate IF Age less than 10 DISPLAY Allowance ELSE CALCULATE Allowance = Age x OlderRate Loop statements: Repeatedly execute the same statement(s) for a certain number of times or until a test condition is satisfied. COMPUTE Population = Population + Births - Deaths WHILE Population UNDER Limit DO Calculate the total allowance paid to each of three children at $1 per year old. $1 per year Rate 3 NumKids Ages of children Total Allowance paid Set Total to 0 Set KidsPaid to 0 WHILE KidsPaid under 3 DO CALCULATE Allowance = Age x Rate Read Age ADD Allowance to Total DISPLAY Total INCREMENT KidsPaid   Dept. of CSE Lecturer Farazul H Bhuiyan Bangladesh BRAC University

Flow Chart - Flow Control Design Tool Flowchart - a graphical way of writing algorithms Rectangle is used for calculations Parallelogram is used for input and output Circle is used as connector Diamond is used as decision Symbols are connected by arrows to represent the order of the operations

Flow Chart – Flow Control Symbol Process Alternet Process Decision Data Predefined Process Internal Storage Terminator Document Manual Input Manual Operation Connector Display Stored Data Extract - Marge

Flow Chart – Flow Control Symbol Every solution starts somewhere and terminates somewhere Every flowchart must have one start symbol and one end symbol Start and end symbols are ovals Start Stop Solution A start symbol denotes the start of the algorithm An end symbol indicates the algorithm has terminated

Flow Chart – Flow Control Symbol Build an application that asks User to input two numbers. Then Calculates the sum of the two numbers Outputs the sum. Input first_number Input second_number Sum = first_number + second_number Output Sum Stop

Flow Chart – Flow Control Symbol Allow1 = Age1 x Rate input Age1 start Print Allow1 stop prompt Age1 Allow2 = Age2 x Rate Print Allow2 input Age2 prompt Age2 Calculate two children‘s allowances, based upon 75 cents per year old. Previous Pseudocode Algorithm: READ Age of Child1 PROMPT for Age of Child1 READ Age of Child2 PROMPT for Age of Child2 CALCULATE Allowance for Child1 = Age of Child1 x Rate CALCULATE Allowance for Child2 = Age of Child2 x Rate DISPLAY Allowance for Child1 DISPLAY Allowance for Child2

Flow Chart – Flow Control Symbol Start Take 2 number from user and find out which one is a bigger number Input first_number Input second_number Is first_number greater than second_number? YES NO Output first_number is bigger Output second_number is bigger Stop

Flow Chart – Flow Control Symbol Start Input first_number Input second_number Sum = first_number + second_number Is first_number greater than second_number? TRUE FALSE Output Sum & first_number is bigger Output Sum & second_number is bigger Stop

Flow Chart – Flow Control Symbol Lets think about this … Start Write a program to output the sum of 1 to 10. That is, 1 + 2 + 3 + 4 + 5 + 6 +7 +8 +9 +10 Sum =0 Number = 1 Sum = Sum + Number Is Number < 10? Number = Number +1 True False Output Sum Stop

Flow Chart – Flow Control Symbol Calculate one child’s allowance, based upon 75 cents per year old if s/he is under 10, and $1 per year if 10 or over. Allow = Age x YoungRate start Print Allow stop prompt Age Allow = Age x OlderRate Age < 10 FALSE TRUE input Age Previous Pseudocode Algorithm: PROMPT for Age READ Age IF Age less than 10 THEN CALCULATE Allowance = Age x YoungRate ELSE CALCULATE Allowance = Age x OlderRate DISPLAY Allowance

Flow Chart – Flow Control Symbol Calculate the total allowance paid to each of three children at $1 per year old. start Display Total stop Read Age Calc Allowance KidsPaid < 3 FALSE TRUE KidsPaid = 0 Total = 0 Add Allowance to Total Increment KidsPaid Prompt Age Previous Pseudo code Algorithm: Set KidsPaid to 0 Set Total to 0 WHILE KidsPaid < 3 DO PROMPT for Age READ Age CALCULATE Allowance = Age x Rate ADD Allowance to Total INCREMENT KidsPaid DISPLAY Total

Flow Chart – Flow Control Symbol Start Input N I = 1 When I<=N Output I I = I+ 2 End Write pseudo code and draw flowchart for printing Sequesnce:1,3,5,9,…. N 1. Start 2. Input N 3. Set Count = 1 4. If Count < N 4a. Yes go to Step 5 4b. No, go to Step 7 5. Print Count 6. Count = Count +2 , Go to Step 4 7. End

Any Question Spring 2016 Farazul H Bhuiyan Lecturer Dept. of CSE   Farazul H Bhuiyan Lecturer Dept. of CSE BRAC University Bangladesh Spring 2016