The University of Texas – Pan American

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

INSTRUCTOR: SHIH-SHINH HUANG Windows Programming Using Java Chapter4: Control Statements Part I.
Chapter 4 - Control Structures: Part 1 Outline 4.4Control Structures 4.5The if Selection Structure 4.6The if/else Selection Structure 4.7The while Repetition.
Chapter 8 . Sequence Control
CSCI/CMPE 4341 Topic: Programming in Python Chapter 3: Control Structures (Part 1) – Exercises 1 Xiang Lian The University of Texas – Pan American Edinburg,
CSCI/CMPE 4341 Topic: Programming in Python Chapter 6: Lists, Tuples, and Dictionaries – Exercises Xiang Lian The University of Texas – Pan American Edinburg,
The University of Texas – Pan American
Sequence Control Chapter 6. 2 l Control structures: the basic framework within which operations and data are combined into programs. Sequence control.
Chapter 5: Control Structures II (Repetition)
CHAPTER 5: CONTROL STRUCTURES II INSTRUCTOR: MOHAMMAD MOJADDAM.
EGR 2261 Unit 5 Control Structures II: Repetition  Read Malik, Chapter 5.  Homework #5 and Lab #5 due next week.  Quiz next week.
The University of Texas – Pan American
Lecture 4 C Program Control Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II UTPA – Fall
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 1B) UTPA – Fall 2011.
Chapter 5: Control Structures II (Repetition). Objectives In this chapter, you will: – Learn about repetition (looping) control structures – Learn how.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley.
Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection Structure 3.6The.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
Lecture 2 Control Structure. Relational Operators -- From the previous lecture Relational Operator Meaning == is equal to < is less than > is greater.
 Pearson Education, Inc. All rights reserved Control Statements: Part 1.
CSCI/CMPE 4341 Topic: Programming in Python Review: Exam I Xiang Lian The University of Texas – Pan American Edinburg, TX 78539
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX.
CSCI 3328 Object Oriented Programming in C# Chapter 8: LINQ and Generic Collections – Exercises 1 Xiang Lian The University of Texas – Pan American Edinburg,
 2003 Prentice Hall, Inc. All rights reserved. 1 Will not cover 4.14, Thinking About Objects: Identifying Class Attributes Chapter 4 - Control Structures.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 4: Control Structures (Part 2) Xiang Lian The University of Texas – Pan American Edinburg, TX
C Language 1 Program Looping. C Language2 Topics Program looping Program looping Relational operators / expressions Relational operators / expressions.
CSCI 3328 Object Oriented Programming in C# Chapter 6: Methods – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 5: Control Structures II (Repetition)
ECE122 Feb 10, Unary Operator An operator that takes only a single operand Plus: + Minus: – Cast: (type). E.g. (double)
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 2: Control Structures (Selection & Repetition)
C Program Control September 15, OBJECTIVES The essentials of counter-controlled repetition. To use the for and do...while repetition statements.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 7: Introduction to Object- Oriented Programming in Python – Exercises Xiang Lian The University of.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 5: Functions – Exercises Xiang Lian The University of Texas – Pan American Edinburg, TX 78539
1 Chapter 4 - Control Statements: Part 1 Outline 4.1 Introduction 4.4 Control Structures 4.5 if Selection Structure 4.6 if/else Selection Structure 4.7.
Chapter 7 JavaScript: Control Statements, Part 1
Topic 4: Looping Statements
Lecture 7: Repeating a Known Number of Times
Control Statements: Part 1
JavaScript: Control Statements I
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2B) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
Ch 7: JavaScript Control Statements I.
JavaScript: Control Statements I
The University of Texas – Pan American
The University of Texas – Pan American
The University of Texas Rio Grande Valley
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I UTPA – Fall 2012 This set of slides is revised from lecture slides.
The University of Texas – Pan American
The University of Texas – Pan American
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I – Exercises UTPA – Fall 2012 This set of slides is revised from lecture.
MSIS 655 Advanced Business Applications Programming
CSCI 3328 Object Oriented Programming in C# Review: Exam I
CSCI 3328 Object Oriented Programming in C# Chapter 9: Classes and Objects: A Deeper Look – Exercises UTPA – Fall 2012 This set of slides is revised from.
The University of Texas – Pan American
CSCI 3328 Object Oriented Programming in C# Review: Exam I
The University of Texas Rio Grande Valley
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II – Exercises UTPA – Fall 2012 This set of slides is revised from.
3 Control Statements:.
The University of Texas – Pan American
CSCI 3328 Object Oriented Programming in C# Chapter 3: Introduction to Classes and Objects – Exercises UTPA – Fall 2012 This set of slides is revised.
The University of Texas – Pan American
CSCI 3327 Visual Basic Review: Exam I
CSCI 3328 Object Oriented Programming in C# Review: Final Exam
The University of Texas – Pan American
CSCI 3328 Object Oriented Programming in C# Review: Final Exam
CSCI 3328 Object Oriented Programming in C# Review: Exam II
CSCI 3328 Object Oriented Programming in C# Chapter 7: Arrays – Exercises UTPA – Fall 2012 This set of slides is revised from lecture slides of Prof.
Control Statements:.
Presentation transcript:

The University of Texas – Pan American CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I – Exercises Xiang Lian The University of Texas – Pan American Edinburg, TX 78539 lianx@utpa.edu This set of slides is revised from lecture slides of Prof. John Abraham. -- Xiang Lian

Objectives In this chapter, you will do some exercises about: basic control structures in Visual C#

Precedence of Operators . new ++ (postfix) -- (postfix) ++ -- + - (unary) * / % + - < <= > >= == != ? : = += -= *= /= %= high low

Multiple Choices Which of the following is not an attribute of an airplane? A. length B. wingspan C. fly D. number of seats All applications can be written in terms of three types of control structures except for: A. sequence B. selection C. random D. repetition The ________ statement is used to execute one action when a condition is true and another when that condition is false. A. repetition B. selection C. inheritance D. conditional Repeating a set of instructions a specific number of times is called _______ repetition. A. EOF-controlled B. flag-controlled C. counter-controlled D. sentinel-controlled When it is not known in advance how many times a set of instructions will be repeated, a(n) ________ value cannot be used to terminate the repetition. A. flag B. signal C. counter D. sentinel

Multiple Choices (cont'd) The _______ structure is built into C# -- by default, statements execute in the order they appear A. sequence B. selection C. repetition D. goto Instance variables of type int are given the value ______ by default. A. 0 B. NULL C. "" D. 1 C# is a ___________ language – it requires all variables to have a type. A. strongly-typed B. weak-typed C. wield-typed D. object-typed If the increment operator is _____ to a variable, the variable is incremented by 1 first, then its new value is used in the expression A. prefixed B. postfixed C. infixed D. None of the above The expression to the right of an assignment operator (=) is evaluated ______the assignment occurs. A. before B. after C. at the same time D. none of the above

True/False Statements An algorithm is a procedure for solving a problem in terms of the actions to execute and the order in which these actions execute. A set of statements contained within a pair of parentheses is called a block. A selection statement specifies that an action is to be repeated while some condition remains true. A nested control statement appears in the body of another control statement.

True/False Statements (cont'd) C# provides the arithmetic compound assignment operators +=, -=, *=, /=, and %= for abbreviating assignment expressions. Specifying the order in which statements (actions) execute in an application is called program control. The unary cast operator (double) creates a temporary integer copy of its operand. Instance variables of type bool are given the value true by default Pseudo code helps you think out an application before attempting to write it in a programming language.

What are the Precedence of Operators in Expressions? 15*3%12+45/(9%2)*-2 Product *= x++;

Debug Errors public static main(string []args) { Int x=0; x=y; WriteLine(x); }

Debug Errors (cont'd) public static main(string []args) { if (gender = 1) Console.WriteLine("Woman"); else; Console.WriteLine("Man"); }

Debug Errors (cont'd) public static main(string []args) { int counter = 0; While (counter > 10) Console.WriteLine(counter); return; }

Programming Write 4 different C# statements that each add 1 to int variable x.

Programming (cont'd) Write a console program using nested while loop to output the following pattern to screen: * ** *** **** *****