C Programming. Lecture no. 2 More on Control Statements

Size: px
Start display at page:

Download "C Programming. Lecture no. 2 More on Control Statements"

Transcription

1 C Programming Lecture no. 2 More on Control Statements

2 คำส งในกำรควบค มโปรแกรม 2

3 คำส ง if อย ำงง ำย ค ำส ง if เป นค ำส งสำหร บกำร สร ำงสำยกำรควบค มกำรท ำงำน ออกเป น 2 สำย ร ปแบบ if (condition) statement; Ex: if (height >= 180) { printf( You are very Tall\n ); 3

4 คำส ง if / คำส งเง อนไข if... ร ปแบบ if <condition> statement1; statement2; condition = เง อนไขในการต ดส นใจ statement = คาส งหร อกล มคาส ง ต วอย ำง if (score>80) printf ( Excellent ); printf ( Good ); 4

5 Flow Chart ของคำส งเง อนไข Yes Condition No Statement 1 Statement 2 5

6 Activity Break if (x == 0.0) printf ("x is equal to 0.\n"); y = 0; printf ("x is greater or less than 0.\n"); y = 1; 6

7 Activity Break if (x == 0.0) { printf("x is equal to 0.\n"); y = 0; printf("x is greater or less than 0.\n"); y = 1; 7

8 Activity Break if (x == 0.0) { printf("x is equal to 0.\n"); y = 0; { printf("x is greater or less than 0.\n"); y = 1; 8

9 คำส ง if / หลำยทำงเล อก คำส งเง อนไข if... if ร ปแบบ if <condition1> statement1; if <condition2> statement2; statement3; ต วอย ำง 0 <= x <= 69 : Standard 70 <= x <= 79 : Good x >= 80 : Very Good if (score >= 80) printf ( Very Good ); if (score >= 70) printf ( Good ); printf ( Standard ); 9

10 If-then- a review Let s start out by reviewing what we know about the ifthen- statement 10

11 if statement if (Age < 18) { printf( A child!\n ); 11

12 if- statement if (Age < 18) { printf( A child!\n ); { printf( An adult!\n ); 12

13 if--if statement if (Age < 13) { printf( A child!\n ); if ((Age >= 13 ) && (Age <= 17)) { printf( A teenager!\n ); { printf( An adult!\n ); 13

14 Braces { if (Age < 13) printf( A child!\n ); if ((Age >= 13 ) && (Age <= 17)) printf( A teenager!\n ); printf( An adult!\n ); Not required if branch has only one statement. We recommend you always use braces in this course. Sometimes we omit them to fit our examples on a slide. 14

15 Nested if/ if (Gender == M ) if (Age < 18) printf( A male child!\n ); printf( A man!\n ); if (Age < 18) printf( A female child!\n ); printf( A woman!\n ); Nested if/ is different from if--if... 15

16 Nested if/ vs if-then--if Age < 13 Age >= 13 && child Age <= 17 teenager Age > 17 adult Age < 18 Gender = M Age < 18 male child man female child woman 16

17 Activity Can our nested if/ example be re-code as an if-then-if? If so, do so! If so, can a nested if/ always be re-coded as an if-then-if? If so, why not always use if-then--if instead of a nested if/? 17

18 Activity Break 18

19 Activity Feedback if ((Gender == M ) && (Age < 18)) printf( A male child!\n ); if (Gender == M ) printf( A man!\n ); if (Age < 18) printf( A female child!\n ); printf( A woman!\n ); 19

20 Activity Feedback Nested if/ can always be re-coded as an if-then--if. We do not always use if-then--if instead of a nested if/ because: conditions become more complicated we may wish to perform some common processing for all cases in a sub-branch 20

21 Activity Feedback if (Gender == M ) { NbrMales = NbrMales + 1; if (Age < 18) printf( A male child!\n ); printf( A man!\n ); { : 21

22 Handling other cases One must always be aware of the need to handle other cases.. What are the cases that we are expected to be able to handle? Do we need to consider the possibility of encountering other cases? If so, how should we handle them? 22

23 Nested if/ if (Gender == M ) if (Age < 18) printf( A male child!\n ); printf( A man!\n ); if (Gender == F ) if (Age < 18) printf( A female child!\n ); printf( A woman!\n ); printf( Unknown gender!\n ); 23

24 Activity (เง อนไขท ไม จำเป น) if (x < 0.0) { range = 0; if (x >= 0.0 && x < 10.0) { range = 1; if (x >= 10.0 && x < 100.0) { range = 2; range = 3; if (x < 0.0) { range = 0; if (x < 10.0) { range = 1; if (x < 100.0) { range = 2; range = 3; 24

25 คำส ง switch คำส งเง อนไข Switch ร ปแบบ switch(variable) { case constant1: statement1; break; case constant2: statement2; break; variable = ต วแปร หร อ น พจน constant = ค าคงท ชน ด int หร อ char ท เป นต วเล อกทางาน 25

26 Flow Chart ของคำส งแบบหลำยเง อนไข Condition 1 Yes Statement 1 No Condition 2 Yes No Condition 3 No Statement 2 Yes Statement 3 Statement 4 26

27 If--if if (day == 1) printf ("Sunday\n"); if (day == 2) printf ("Monday\n"); if (day == 3) printf ("Tuesday\n"); if (day ==4) printf ("Wednesday\n"); if (day ==5) printf ("Thursday\n"); if (day ==6) printf ("Friday\n"); if (day ==7) printf ("Saturday\n"); printf ("Unknown\n") switch (expression) { case constant1 : statement_sequence1 break; case constant2 : statement_sequence2 break;... case constantn : statement_sequencen break; default : statement_sequencen+1 27

28 If--if and Switch if (day == 1) printf ("Sunday\n"); if (day == 2) printf ("Monday\n"); if (day == 3) printf ("Tuesday\n"); if (day ==4) printf ("Wednesday\n"); if (day ==5) printf ("Thursday\n"); if (day ==6) printf ("Friday\n"); if (day ==7) printf ("Saturday\n"); printf ("Unknown\n") switch (day) { case 1 : printf ("Sunday\n"); break; case 2 : printf ("Monday\n"); break; case 3 : printf ("Tuesday\n"); break; case 4 : printf ("Wednesday\n"); break; case 5 : printf ("Thursday\n"); break; case 6 : printf ("Friday\n"); break; case 7 : printf ("Saturday\n"); break; default : printf ("Unknown option! \n"); 28

29 Activity switch (digit) { case 2: case 3: case 5: case 7: printf("%d is a prime number.\n", digit); break; default: if (digit >= 0 && digit <= 9) printf("%d is not a prime number.\n", digit); printf("invalid option: %d\n", digit); 29

30 END

C Programming

C Programming 204216 -- C Programming Chapter 5 Repetition Adapted/Assembled for 204216 by Areerat Trongratsameethong Objectives Basic Loop Structures The while Statement Computing Sums and Averages Using a while Loop

More information

CMSC 104 -Lecture 11 John Y. Park, adapted by C Grasso

CMSC 104 -Lecture 11 John Y. Park, adapted by C Grasso CMSC 104 -Lecture 11 John Y. Park, adapted by C Grasso 1 Topics Multiple Selection vs Binary Selection switch Statement char data type and getchar( ) function Reading newline characters 2 So far, we have

More information

Introduction to Programming

Introduction to Programming Introduction to Programming ( 數 ) Lecture 4 Spring 2005 March 11, 2005 Topics Review of if statement The switch statement Repetition and Loop Statements For-Loop Condition-Loop Reading: Chap. 5.7~ Chap.

More information

ว ธ การต ดต ง Symantec Endpoint Protection

ว ธ การต ดต ง Symantec Endpoint Protection ว ธ การต ดต ง Symantec Endpoint Protection 1. Download File ส าหร บการต ดต ง 2. Install Symantec Endpoint Protection Manager 3. Install License 4. Install Symantec Endpoint Protection Client to Server

More information

Flow of Control. Flow of control The order in which statements are executed. Transfer of control

Flow of Control. Flow of control The order in which statements are executed. Transfer of control 1 Programming in C Flow of Control Flow of control The order in which statements are executed Transfer of control When the next statement executed is not the next one in sequence 2 Flow of Control Control

More information

V2 2/4/ Ch Programming in C. Flow of Control. Flow of Control. Flow of control The order in which statements are executed

V2 2/4/ Ch Programming in C. Flow of Control. Flow of Control. Flow of control The order in which statements are executed Programming in C 1 Flow of Control Flow of control The order in which statements are executed Transfer of control When the next statement executed is not the next one in sequence 2 Flow of Control Control

More information

Basic computer skills such as using Windows, Internet Explorer, and Microsoft Word. and Java. Chapter 2 Primitive Data Types and Operations

Basic computer skills such as using Windows, Internet Explorer, and Microsoft Word. and Java. Chapter 2 Primitive Data Types and Operations Basic computer skills such as using Windows, Internet Explorer, and Microsoft Word Chapter p 1 Introduction to Computers, p, Programs, g, and Java Chapter 2 Primitive Data Types and Operations Chapter

More information

C Programming

C Programming 204216 -- C Programming Chapter 9 Character Strings Adapted/Assembled for 204216 by Areerat Trongratsameethong A First Book of ANSI C, Fourth Edition Objectives String Fundamentals Library Functions Input

More information

1.4 Control Structures: Selection. Department of CSE

1.4 Control Structures: Selection. Department of CSE 1.4 Control Structures: Selection 1 Department of CSE Objectives To understand how decisions are made in a computer To understand the relational operators To understand the logical operators and,or and

More information

Objectives. Data Types (continued) Data Types 4. การเข ยนโปรแกรมพ นฐาน ว ทยาการคอมพ วเตอร เบ องต น Fundamentals of Computer Science

Objectives. Data Types (continued) Data Types 4. การเข ยนโปรแกรมพ นฐาน ว ทยาการคอมพ วเตอร เบ องต น Fundamentals of Computer Science 204111 ว ทยาการคอมพ วเตอร เบ องต น Fundamentals of Computer Science ภาคการศ กษาท ภาคการศกษาท 1 ป ปการศกษา การศ กษา 2556 4. การเข ยนโปรแกรมพ นฐาน 4.2 ต วแปร น พจน และการก าหนดค า รวบรวมโดย อ. ดร. อาร ร

More information

UNIT 4. CONTROL FLOW. Programming Year Grade in Industrial Technology Engineering. Paula de Toledo. David Griol

UNIT 4. CONTROL FLOW. Programming Year Grade in Industrial Technology Engineering. Paula de Toledo. David Griol Programming Unit 4. Control flow Haga clic para modificar el estilo de texto del patrón UNIT 4. CONTROL FLOW Programming Year 2017-2018 Grade in Industrial Technology Engineering Paula de Toledo. David

More information

เคร องว ดระยะด วยแสงเลเซอร แบบม อถ อ ย ห อ Leica DISTO ร น D110 (Bluetooth Smart) ประเทศสว ตเซอร แลนด

เคร องว ดระยะด วยแสงเลเซอร แบบม อถ อ ย ห อ Leica DISTO ร น D110 (Bluetooth Smart) ประเทศสว ตเซอร แลนด เคร องว ดระยะด วยแสงเลเซอร แบบม อถ อ ย ห อ Leica DISTO ร น D110 (Bluetooth Smart) ประเทศสว ตเซอร แลนด 1. ค ณล กษณะ 1.1 เป นเคร องว ดระยะทางด วยแสงเลเซอร แบบม อถ อ 1.2 ความถ กต องในการว ดระยะทางไม เก น

More information

การเขยนโปรแกรมพนฐาน ภาคการศ กษาท 1 ป การศ กษา การเข ยนโปรแกรมพ นฐาน ว ทยาการคอมพ วเตอร เบ องต วทยาการคอมพวเตอรเบองตน น

การเขยนโปรแกรมพนฐาน ภาคการศ กษาท 1 ป การศ กษา การเข ยนโปรแกรมพ นฐาน ว ทยาการคอมพ วเตอร เบ องต วทยาการคอมพวเตอรเบองตน น 204111 ว ทยาการคอมพ วเตอร เบ องต วทยาการคอมพวเตอรเบองตน น Fundamentals of Computer Science ภาคการศ กษาท 1 ป การศ กษา 2556 4. การเข ยนโปรแกรมพ นฐาน การเขยนโปรแกรมพนฐาน 4.2 ต วแปร น พจน และการก าหนดค า รวบรวมโดย

More information

Selection Control Structure CSC128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING

Selection Control Structure CSC128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING Selection Control Structure CSC128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING MULTIPLE SELECTION To solve a problem that has several selection, use either of the following method: Multiple selection nested

More information

IS311 Programming Concepts 2/59. AVA Exception Handling Jการจ ดการส งผ ดปรกต

IS311 Programming Concepts 2/59. AVA Exception Handling Jการจ ดการส งผ ดปรกต 1 IS311 Programming Concepts 2/59 AVA Exception Handling Jการจ ดการส งผ ดปรกต 2 Introduction Users have high expectations for the code we produce. Users will use our programs in unexpected ways. Due to

More information

Lab 10: Structs and Enumeration

Lab 10: Structs and Enumeration Lab 10: Structs and Enumeration There is one more way to create your own value types in C#. You can use the struct keyword. A struct (short for structure) can have its own fields, methods, and constructors

More information

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-3 Flow Of Control Flow of control refers to the

More information

Introduction. C provides two styles of flow control:

Introduction. C provides two styles of flow control: Introduction C provides two styles of flow control: Branching Looping Branching is deciding what actions to take and looping is deciding how many times to take a certain action. Branching constructs: if

More information

Chapter 3 Outline. Relational Model Concepts. The Relational Data Model and Relational Database Constraints Database System 1

Chapter 3 Outline. Relational Model Concepts. The Relational Data Model and Relational Database Constraints Database System 1 Chapter 3 Outline 204321 - Database System 1 Chapter 3 The Relational Data Model and Relational Database Constraints The Relational Data Model and Relational Database Constraints Relational Model Constraints

More information

I/O. Output. Input. Input ของจาวา จะเป น stream จะอ าน stream ใช คลาส Scanner. standard input. standard output. standard err. command line file.

I/O. Output. Input. Input ของจาวา จะเป น stream จะอ าน stream ใช คลาส Scanner. standard input. standard output. standard err. command line file. I/O and Exceptions I/O Input standard input keyboard (System.in) command line file Output standard output Screen (System.out) standard err file System.err Input ของจาวา จะเป น stream จะอ าน stream ใช คลาส

More information

ISI Web of Science. SciFinder Scholar. PubMed ส บค นจากฐานข อม ล

ISI Web of Science. SciFinder Scholar. PubMed ส บค นจากฐานข อม ล 2.3.3 Search Chem. Info. in Journal ส บค นจากฐานข อม ล - ฐานข อม ลท รวบรวมข อม ลของ journal จากหลาย ๆ แหล ง ISI http://portal.isiknowledge.com/portal.cgi/ SciFinder ต องต ดต งโปรแกรมพ เศษ และสม ครสมาช

More information

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting Your factors.c and multtable.c files are due by Wednesday, 11:59 pm, to be submitted on the SoC handin page at http://handin.cs.clemson.edu.

More information

SEARCH STRATEGIES KANOKWATT SHIANGJEN COMPUTER SCIENCE SCHOOL OF INFORMATION AND COMMUNICATION TECHNOLOGY UNIVERSITY OF PHAYAO

SEARCH STRATEGIES KANOKWATT SHIANGJEN COMPUTER SCIENCE SCHOOL OF INFORMATION AND COMMUNICATION TECHNOLOGY UNIVERSITY OF PHAYAO SEARCH STRATEGIES KANKWATT SHIANGJEN CMPUTER SCIENCE SCHL F INFRMATIN AND CMMUNICATIN TECHNLGY UNIVERSITY F PHAYA Search Strategies Uninformed Search Strategies (Blind Search): เป นกลย ทธ การ ค นหาเหม

More information

INPUT Input point Measuring cycle Input type Disconnection detection Input filter

INPUT Input point Measuring cycle Input type Disconnection detection Input filter 2 = TEMPERATURE CONTROLLER PAPERLESS RECORDER หน าจอเป น Touch Sceen 7-Inch LCD เก บข อม ลผ าน SD Card และ USB Memory ร บ Input เป น TC/RTD/DC Voltage/DC Current ร บ Input 6 Channel ช วงเวลาในการอ านส

More information

ร จ กก บ MySQL Cluster

ร จ กก บ MySQL Cluster ร จ กก บ MySQL Cluster ก ตต ร กษ ม วงม งส ข (Kittirak Moungmingsuk) kittirak@clusterkit.co.th May 19, 2012 @ossfestival #11 `whoami` A part of team at Cluster Kit Co.,Ltd. Since 2007. Adjacent Lecturer

More information

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes Overview For this lab, you will use: one or more of the conditional statements explained below

More information

CpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input

CpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input CpSc Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input Overview For this lab, you will use: one or more of the conditional statements explained below scanf() or fscanf() to read

More information

What s Hot & What s New from Microsoft ส มล อน นตธนะสาร Segment Marketing Manager

What s Hot & What s New from Microsoft ส มล อน นตธนะสาร Segment Marketing Manager What s Hot & What s New from Microsoft ส มล อน นตธนะสาร Segment Marketing Manager 1 โปรแกรมท น าสนใจส าหร บไตรมาสน Crisis Turing Point II Oct-Dec 09 Windows 7 งานเป ดต วสาหร บล กค าท วไป, Paragon Hall,

More information

C Programming Basics

C Programming Basics CSE 2421: Systems I Low-Level Programming and Computer Organization C Programming Basics Presentation B Read/Study: Reek 3.1-3.4, 4, and 5, Bryant 2.1.1-2.1.5 Gojko Babić 08/29/2017 C Programming Language

More information

INTRODUCTION TO C++ PROGRAM CONTROL. Dept. of Electronic Engineering, NCHU. Original slides are from

INTRODUCTION TO C++ PROGRAM CONTROL. Dept. of Electronic Engineering, NCHU. Original slides are from INTRODUCTION TO C++ PROGRAM CONTROL Original slides are from http://sites.google.com/site/progntut/ Dept. of Electronic Engineering, NCHU Outline 2 Repetition Statement for while do.. while break and continue

More information

Repetition Structures II

Repetition Structures II Lecture 9 Repetition Structures II For and do-while loops CptS 121 Summer 2016 Armen Abnousi Types of Control Structures Sequential All programs that we have written so far The statements inside a pair

More information

Branching is deciding what actions to take and Looping is deciding how many times to take a certain action.

Branching is deciding what actions to take and Looping is deciding how many times to take a certain action. 3.0 Control Statements in C Statements The statements of a C program control the flow of program execution. A statement is a command given to the computer that instructs the computer to take a specific

More information

Chapter 13 Control Structures

Chapter 13 Control Structures Chapter 13 Control Structures Control Structures Conditional making a decision about which code to execute, based on evaluated expression if if-else switch Iteration executing code multiple times, ending

More information

Microsoft Windows7. The Trainer. Microsoft Windows7. Name : Phattharaphon Khajornchaiyakul Nickname : Phat

Microsoft Windows7. The Trainer. Microsoft Windows7. Name : Phattharaphon Khajornchaiyakul Nickname : Phat Microsoft Windows7 1 The Trainer Name : Phattharaphon Khajornchaiyakul Nickname : Phat Email : ibwiw@hotmail.com 2 www.npssolution.com : 081-8836286 1 Understanding Windows 7 The Different Versions of

More information

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University ITC213: STRUCTURED PROGRAMMING Bhaskar Shrestha National College of Computer Studies Tribhuvan University Lecture 08: Control Statements Readings: Chapter 6 Control Statements and Their Types A control

More information

Lecture 6. Statements

Lecture 6. Statements Lecture 6 Statements 1 Statements This chapter introduces the various forms of C++ statements for composing programs You will learn about Expressions Composed instructions Decision instructions Loop instructions

More information

Decisions. Arizona State University 1

Decisions. Arizona State University 1 Decisions CSE100 Principles of Programming with C++, Fall 2018 (based off Chapter 4 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University

More information

Lecture 6 Register Transfer Methodology. Pinit Kumhom

Lecture 6 Register Transfer Methodology. Pinit Kumhom Lecture 6 Register Transfer Methodology Pinit Kumhom VLSI Laboratory Dept. of Electronic and Telecommunication Engineering (KMUTT) Faculty of Engineering King Mongkut s University of Technology Thonburi

More information

CMSC 104 -Lecture 9 John Y. Park, adapted by C Grasso

CMSC 104 -Lecture 9 John Y. Park, adapted by C Grasso CMSC 104 -Lecture 9 John Y. Park, adapted by C Grasso 1 Topics The while Loop Program Versatility Sentinel Values and Priming Reads Checking User Input Using a while Loop 2 A repetition structureallows

More information

Chapter 3. More Flow of Control. Copyright 2008 Pearson Addison-Wesley. All rights reserved.

Chapter 3. More Flow of Control. Copyright 2008 Pearson Addison-Wesley. All rights reserved. Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-3 Flow Of Control Flow of control refers to the

More information

Introduction. Pretest and Posttest Loops. Basic Loop Structures ว ทยาการคอมพ วเตอร เบ องต น Fundamentals of Computer Science

Introduction. Pretest and Posttest Loops. Basic Loop Structures ว ทยาการคอมพ วเตอร เบ องต น Fundamentals of Computer Science 204111 ว ทยาการคอมพ วเตอร เบ องต น Fundamentals of Computer Science ภาคการศ กษาท ภาคการศกษาท 1 ป ปการศกษา การศ กษา 2556 4. การเข ยนโปรแกรมพ นฐาน 4.5 โครงสร างควบค มแบบท าซ า รวบรวมโดย อ. ดร. อาร ร ตน ตรงร

More information

Introduction to Computing Lecture 05: Selection (continued)

Introduction to Computing Lecture 05: Selection (continued) Introduction to Computing Lecture 05: Selection (continued) Assist.Prof.Dr. Nükhet ÖZBEK Ege University Department of Electrical & Electronics Engineering nukhet.ozbek@ege.edu.tr Topics Type int as Boolean

More information

Using Boolean Expressions. Multiway Branches. More about C++ Loop Statements. Designing Loops. In this chapter, you will learn about:

Using Boolean Expressions. Multiway Branches. More about C++ Loop Statements. Designing Loops. In this chapter, you will learn about: Chapter 3 In this chapter, you will learn about: Using Boolean Expressions Multiway Branches More about C++ Loop Statements Designing Loops Boolean Expressions Take the Value true or false Boolean Value

More information

SQL. Assit.Prof Dr. Anantakul Intarapadung

SQL. Assit.Prof Dr. Anantakul Intarapadung SQL Assit.Prof Dr. Anantakul Intarapadung SQL Introduction SQL (Structured Query Language) เป นภาษามาตรฐานท ใช สาหร บการเร ยกด ข อม ล (querying )และบร หาร จ ดการข อม ล ภาษาน ถ กพ ฒนามาหลากหลายเวอร ช น

More information

5. Selection: If and Switch Controls

5. Selection: If and Switch Controls Computer Science I CS 135 5. Selection: If and Switch Controls René Doursat Department of Computer Science & Engineering University of Nevada, Reno Fall 2005 Computer Science I CS 135 0. Course Presentation

More information

Broken Characters Identification for Thai Character Recognition Systems

Broken Characters Identification for Thai Character Recognition Systems Broken Characters Identification for Thai Character Recognition Systems NUCHAREE PREMCHAISWADI*, WICHIAN PREMCHAISWADI* UBOLRAT PACHIYANUKUL**, SEINOSUKE NARITA*** *Faculty of Information Technology, Dhurakijpundit

More information

PRICE LIST Video Transmission Fiber Optic Cable TEL: (May 2015) HD-AHD CCTV System

PRICE LIST Video Transmission Fiber Optic Cable TEL: (May 2015)  HD-AHD CCTV System COMMUNICATION PRODUCTS Video Transmission Fiber Optic Cable PRICE LIST 2015 HD-AHD CCTV System HD-CVI CCTV System HD-TVI CCTV System Analog CCTV System (May 2015) www.facebook.com/bismonthailand TEL: 0-2563-5000

More information

Unit 3 Decision making, Looping and Arrays

Unit 3 Decision making, Looping and Arrays Unit 3 Decision making, Looping and Arrays Decision Making During programming, we have a number of situations where we may have to change the order of execution of statements based on certain conditions.

More information

Chapter 4. Introducing Oracle Database XE 11g R2. Oracle Database XE is a great starter database for:

Chapter 4. Introducing Oracle Database XE 11g R2. Oracle Database XE is a great starter database for: Oracle Database XE is a great starter database for: Chapter 4 Introducing Oracle Database XE 11g R2 Developers working on PHP, Java,.NET, XML, and Open Source applications DBAs who need a free, starter

More information

C Language: Review. INFO High Performance Scientific Computing. 26 septembre 2017

C Language: Review. INFO High Performance Scientific Computing. 26 septembre 2017 C Language: Review INFO0939 - High Performance Scientific Computing 26 septembre 2017 Data type int: Basic signed integer type. unsigned int: Basic unsigned (only positive) integer type. float: Real number,

More information

Relational operators (1)

Relational operators (1) Review-2 Control of flow: ifs & loops How to set them up Where to break to When to use which kind 85-132 Introduction to C-Programming 10-1 Relational operators (1) Relational Operators

More information

Conditions and Logical Expressions. C Programming

Conditions and Logical Expressions. C Programming Conditions and Logical Expressions C Programming Lecture Topics Using Relational and Logical Operators to Construct and Evaluate Logical Expressions If-Else Statements Flow of Control is Sequential unless

More information

Chapter 9: Virtual-Memory Management Dr. Varin Chouvatut. Operating System Concepts 8 th Edition,

Chapter 9: Virtual-Memory Management Dr. Varin Chouvatut. Operating System Concepts 8 th Edition, Chapter 9: Virtual-Memory Management Dr. Varin Chouvatut, Silberschatz, Galvin and Gagne 2010 Chapter 9: Virtual-Memory Management Background Demand Paging Copy-on-Write Page Replacement Allocation of

More information

INFINITE. HF RFID Specification

INFINITE. HF RFID Specification INFINITE HF RFID Specification Power Supply 5Vdc (From USB) Interface USB to PC and RS-485 for long distance Frequency 13.56 Mhz Protocol ISO14443A/B, ISO16593, ISO18000-3, Tag-it Read/Write Distance 8

More information

Chapter 13. Control Structures

Chapter 13. Control Structures Chapter 13 Control Structures Control Structures Conditional making a decision about which code to execute, based on evaluated expression if if-else switch Iteration executing code multiple times, ending

More information

2/5/2018. Learn Four More Kinds of C Statements. ECE 220: Computer Systems & Programming. C s if Statement Enables Conditional Execution

2/5/2018. Learn Four More Kinds of C Statements. ECE 220: Computer Systems & Programming. C s if Statement Enables Conditional Execution 2/5/218 University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 22: Computer Systems & Programming Control Constructs in C (Partially a Review) Learn Four More Kinds

More information

โปรแกรมท น าสนใจส าหร บไตรมาสน

โปรแกรมท น าสนใจส าหร บไตรมาสน แคมเปญ และก จกรรมทางการตลาด (ต ลาคม ธ นวาคม 2552) โปรแกรมท น าสนใจส าหร บไตรมาสน Crisis Turing Point II Oct-Dec 09 Windows 7 งานเป ดต วสาหร บล กค าท วไป, Paragon Hall, 31 Oct -1 Nov งานเป ดต วสาหร บล กค

More information

CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point?

CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point? CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point? Overview For this lab, you will use: one or more of the conditional statements explained below scanf()

More information

Computer Science & Engineering 150A Problem Solving Using Computers

Computer Science & Engineering 150A Problem Solving Using Computers Computer Science & Engineering 150A Problem Solving Using Computers Lecture 04 - Conditionals Stephen Scott (Adapted from Christopher M. Bourke) Fall 2009 1 / 1 cbourke@cse.unl.edu Control Structure Conditions

More information

Iosif Ignat, Marius Joldoș Laboratory Guide 4. Statements. STATEMENTS in C

Iosif Ignat, Marius Joldoș Laboratory Guide 4. Statements. STATEMENTS in C STATEMENTS in C 1. Overview The learning objective of this lab is: To understand and proper use statements of C/C++ language, both the simple and structured ones: the expression statement, the empty statement,

More information

There are algorithms, however, that need to execute statements in some other kind of ordering depending on certain conditions.

There are algorithms, however, that need to execute statements in some other kind of ordering depending on certain conditions. Introduction In the programs that we have dealt with so far, all statements inside the main function were executed in sequence as they appeared, one after the other. This type of sequencing is adequate

More information

Chapter Overview. More Flow of Control. Flow Of Control. Using Boolean Expressions. Using Boolean Expressions. Evaluating Boolean Expressions

Chapter Overview. More Flow of Control. Flow Of Control. Using Boolean Expressions. Using Boolean Expressions. Evaluating Boolean Expressions Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Copyright 2011 Pearson Addison-Wesley. All rights reserved.

More information

IS311. Data Structures and Java Collections

IS311. Data Structures and Java Collections IS311 Data Structures and Java Collections 1 Algorithms and Data Structures Algorithm Sequence of steps used to solve a problem Operates on collection of data Each element of collection -> data structure

More information

Decisions (If Statements) And Boolean Expressions

Decisions (If Statements) And Boolean Expressions Decisions (If Statements) And Boolean Expressions CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington Last updated: 2/15/16 1 Syntax if (boolean_expr)

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 5 Structured Program Development Department of Computer Engineering How to develop

More information

Fundamentals of Programming

Fundamentals of Programming Fundamentals of Programming Lecture 5 - Structured Program Development Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad How to develop a program? Requirements Problem Analysis

More information

A First Book of ANSI C Fourth Edition. Chapter 9 Character Strings

A First Book of ANSI C Fourth Edition. Chapter 9 Character Strings A First Book of ANSI C Fourth Edition Chapter 9 Character Strings Objectives String Fundamentals Library Functions Input Data Validation Formatting Strings (Optional) Case Study: Character and Word Counting

More information

<?xml version = 1.0 encoding= windows-874?> <?xml-stylesheet type= text/css href= #xmldocs?> <style id= xmldocs > element-name{ } </style>

<?xml version = 1.0 encoding= windows-874?> <?xml-stylesheet type= text/css href= #xmldocs?> <style id= xmldocs > element-name{ } </style> XML Displaying Displaying XML: CSS A modern web browser and a cascading style sheet (CSS) may be used to view XML as if it were HTML A style must be defined for every XML tag, or the browser displays it

More information

Basic computer skills such as using Windows, Internet Explorer, and Microsoft Word. Chapter 1 Introduction to Computers, Programs, and Java

Basic computer skills such as using Windows, Internet Explorer, and Microsoft Word. Chapter 1 Introduction to Computers, Programs, and Java Chapter 5 Methods Basic computer skills such as using Windows, Internet Explorer, and Microsoft Word Chapter 1 Introduction to Computers, Programs, and Java Chapter 2 Primitive Data Types and Operations

More information

Computer Programming. Decision Making (2) Loops

Computer Programming. Decision Making (2) Loops Computer Programming Decision Making (2) Loops Topics The Conditional Execution of C Statements (review) Making a Decision (review) If Statement (review) Switch-case Repeating Statements while loop Examples

More information

Control Structure: Selection

Control Structure: Selection Control Structure: Selection Knowledge: Understand various concepts of selection control structure Skill: Be able to develop a program containing selection control structure Selection Structure Single

More information

ร ปแบบใหม ของการต ดต อส อสารไร สาย

ร ปแบบใหม ของการต ดต อส อสารไร สาย ร ปแบบใหม ของการต ดต อส อสารไร สาย ค ณล กษณะของต วระบบ Motorola Wireless Canopy เป นอ ปกรณ ส อสารไร สายท ออกแบบมาเพ อการร บส งข อม ลแบบความเร วส ง (Broadband) โดยปราศจากส ญญาณรบกวนต างๆ โดยใช ความถ ย าน

More information

Example. CS 201 Selection Structures (2) and Repetition. Nested if Statements with More Than One Variable

Example. CS 201 Selection Structures (2) and Repetition. Nested if Statements with More Than One Variable CS 201 Selection Structures (2) and Repetition Debzani Deb Multiple-Alternative Decision Form of Nested if Nested if statements can become quite complex. If there are more than three alternatives and indentation

More information

CPE 426 Computer Networks. Chapter 5: Text Chapter 23: Support Protocols

CPE 426 Computer Networks. Chapter 5: Text Chapter 23: Support Protocols CPE 426 Computer Networks Chapter 5: Text Chapter 23: Support Protocols 1 TOPICS สร ปเร อง IP Address Subnetting Chapter 23: Supporting Protocols ARP: 23.1-23.7 ใช ส าหร บหา HW Address(MAC Address) ICMP:

More information

SELECTION STATEMENTS:

SELECTION STATEMENTS: UNIT-2 STATEMENTS A statement is a part of your program that can be executed. That is, a statement specifies an action. Statements generally contain expressions and end with a semicolon. Statements that

More information

Lecture Outline. 1. Semantic Web Technologies 2. A Layered Approach 3. Data Integration

Lecture Outline. 1. Semantic Web Technologies 2. A Layered Approach 3. Data Integration Semantic Web Lecture Outline 1. Semantic Web Technologies 2. A Layered Approach 3. Data Integration Semantic Web Technologies Explicit Metadata Ontologies Logic and Inference Agents 3 On HTML Web content

More information

Control structures in C. Going beyond sequential

Control structures in C. Going beyond sequential Control structures in C Going beyond sequential Flow of control in a program Start (main) Program starts with the first statement in main Instructions proceed sequentially: One at a time Top to bottom

More information

Chapter 3. Legal, Ethical & Professional Issues in Information Security & Network Vulnerabilities and Attacks

Chapter 3. Legal, Ethical & Professional Issues in Information Security & Network Vulnerabilities and Attacks Chapter 3 Legal, Ethical & Professional Issues in Information Security & Network Vulnerabilities and Attacks Resource from : Dr.Sukchatri PRASOMSUK School of Information Technology and Communication, University

More information

FundConnext Restful Web services API Message Specification for No Migration Customer Version 1.6 Aug 20, 2018

FundConnext Restful Web services API Message Specification for No Migration Customer Version 1.6 Aug 20, 2018 FundConnext Restful Web services API Message Specification for No Migration Customer Version 1.6 Aug 20, 2018 Page 1 of 38 Revision Revision Description Updated by Updated Date 0.30 1. Create from standard

More information

Looking forward to a successful coopertation : TEIN

Looking forward to a successful coopertation : TEIN Space Krenovation Park : SKP Looking forward to a successful coopertation : TEIN Geo-Informatics and Space Technology Development Agency : GISTDA Space Krenovation Park @ Chonburi 1 Mission TC/TM House

More information

Subject: PIC Chapter 2.

Subject: PIC Chapter 2. 02 Decision making 2.1 Decision making and branching if statement (if, if-, -if ladder, nested if-) Switch case statement, break statement. (14M) 2.2 Decision making and looping while, do, do-while statements

More information

2017 PROGRAM PORTFOLIO

2017 PROGRAM PORTFOLIO NSTDA Academy National Science and Development Agency,Yothee Office, 73/1 Rama 6 Road Payathai, Ratchathewi, Bangkok 10400, Thailand, Tel: 66 2644 8150 ต อ 81886-7, Fax: 66 2644 8110, www.nstdaacademy.com

More information

COP 2000 Introduction to Computer Programming Mid-Term Exam Review

COP 2000 Introduction to Computer Programming Mid-Term Exam Review he exam format will be different from the online quizzes. It will be written on the test paper with questions similar to those shown on the following pages. he exam will be closed book, but students can

More information

Checking Multiple Conditions

Checking Multiple Conditions Checking Multiple Conditions Conditional code often relies on a value being between two other values Consider these conditions: Free shipping for orders over $25 10 items or less Children ages 3 to 11

More information

JavaScript Framework: AngularJS

JavaScript Framework: AngularJS บทท 8 JavaScript Framework: AngularJS ว ชา เทคโนโลย เว บ (รห สว ชา 04-06-204) ว ตถ ประสงค การเร ยนร เพ อให ผ เร ยนม ความร ความเข าใจเก ยวก บ JavaScript Framework: AngularJS เพ อให ผ เร ยนสามารถนาเสนอการดาเน

More information

Medical Information. Objectives. Literature Search : PubMed. Know. Evaluation. Medical informatics Literature search : PubMed PICO Approach

Medical Information. Objectives. Literature Search : PubMed. Know. Evaluation. Medical informatics Literature search : PubMed PICO Approach Medical Information Literature Search : PubMed Bordin Sapsomboon 20 Aug 2018 http://www.si.mahidol.ac.th/simi bordin.sap@mahidol.ac.th Objectives Know Medical informatics Literature search : PubMed PICO

More information

Chapter 3. More Flow of Control

Chapter 3. More Flow of Control Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-2 Flow Of Control Flow of control refers to the

More information

Chapter 8: Memory- Management Strategies Dr. Varin Chouvatut

Chapter 8: Memory- Management Strategies Dr. Varin Chouvatut Part I: Overview Part II: Process Management Part III : Storage Management Chapter 8: Memory- Management Strategies Dr. Varin Chouvatut, Silberschatz, Galvin and Gagne 2010 Chapter 8: Memory Management

More information

Chapter 2 Control in Programming. lecture 2 1

Chapter 2 Control in Programming. lecture 2 1 Chapter 2 Control in Programming lecture 2 1 Topics Expressions and Statements Blocks and Compound Statements If and If else Statements Relational Operators The While Loop Logical Operations The For Loop

More information

SELECTION. (Chapter 2)

SELECTION. (Chapter 2) SELECTION (Chapter 2) Selection Very often you will want your programs to make choices among different groups of instructions For example, a program processing requests for airline tickets could have the

More information

Note: If only one statement is to be followed by the if or else condition then there is no need of parenthesis.

Note: If only one statement is to be followed by the if or else condition then there is no need of parenthesis. Birla Institute of Technology & Science, Pilani Computer Programming (CSF111) Lab-4 ---------------------------------------------------------------------------------------------------------------------------------

More information

COMP Flow of Control: Branching 2. Yi Hong May 19, 2015

COMP Flow of Control: Branching 2. Yi Hong May 19, 2015 COMP 110-001 Flow of Control: Branching 2 Yi Hong May 19, 2015 Review if else Q1: Write a program that Reads an integer from user Prints Even if the integer is even Otherwise, prints Odd Boolean expression

More information

Selection Structures II

Selection Structures II Lecture 7 Selection Structures II Nested if and switch statements CptS 121 Summer 2016 Armen Abnousi If () if() Nested if statements An if- statement can be placed inside another if- statement. Every matches

More information

CP FAQS Q-1) Define flowchart and explain Various symbols of flowchart Q-2) Explain basic structure of c language Documentation section :

CP FAQS Q-1) Define flowchart and explain Various symbols of flowchart Q-2) Explain basic structure of c language Documentation section : CP FAQS Q-1) Define flowchart and explain Various symbols of flowchart ANS. Flowchart:- A diagrametic reperesentation of program is known as flowchart Symbols Q-2) Explain basic structure of c language

More information

Application Protocols

Application Protocols Application Protocols รศ.ดร. อน นต ผลเพ ม Asso. Prof. Anan Phonphoem, Ph.D. anan.p@ku.ac.th http://www.cpe.ku.ac.th/~anan Computer Engineering Department Kasetsart University, Bangkok, Thailand 1 Outline

More information

Week 2. Relational Operators. Block or compound statement. if/else. Branching & Looping. Gaddis: Chapters 4 & 5. CS 5301 Spring 2018.

Week 2. Relational Operators. Block or compound statement. if/else. Branching & Looping. Gaddis: Chapters 4 & 5. CS 5301 Spring 2018. Week 2 Branching & Looping Gaddis: Chapters 4 & 5 CS 5301 Spring 2018 Jill Seaman 1 Relational Operators l relational operators (result is bool): == Equal to (do not use =)!= Not equal to > Greater than

More information

CS 302: INTRODUCTION TO PROGRAMMING. Lectures 7&8

CS 302: INTRODUCTION TO PROGRAMMING. Lectures 7&8 CS 302: INTRODUCTION TO PROGRAMMING Lectures 7&8 Hopefully the Programming Assignment #1 released by tomorrow REVIEW The switch statement is an alternative way of writing what? How do you end a case in

More information

Decision Making -Branching. Class Incharge: S. Sasirekha

Decision Making -Branching. Class Incharge: S. Sasirekha Decision Making -Branching Class Incharge: S. Sasirekha Branching The C language programs presented until now follows a sequential form of execution of statements. Many times it is required to alter the

More information

Sudeshna Sarkar Dept. of Computer Science & Engineering. Indian Institute of Technology Kharagpur

Sudeshna Sarkar Dept. of Computer Science & Engineering. Indian Institute of Technology Kharagpur Programming and Data Structure Sudeshna Sarkar Dept. of Computer Science & Engineering. Indian Institute of Technology Kharagpur Shortcuts in Assignment Statements A+=C A=A+C A-=B A=A-B A*=D A=A*D A/=E

More information

EECE.2160: ECE Application Programming Spring 2016 Exam 1 Solution

EECE.2160: ECE Application Programming Spring 2016 Exam 1 Solution EECE.2160: ECE Application Programming Spring 2016 Exam 1 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling

More information