6
1 Session-7 CSIT 121 Session-7 CSIT 121 Spring 2006 Spring 2006 Lab Demo of NiMo Lesson 3-2 Exercises 1,2,3,4,5,6 (Arithmetic Operators with Program ‘Convert.cpp’) Q&A about operators and slides of precedence rules from Chapter 3 Lab Demo Exercise Assignment – (Due Feb 16) Practice Questions (Not Due)

Session-7 CSIT 121 Spring 2006

Embed Size (px)

DESCRIPTION

Session-7 CSIT 121 Spring 2006. Lab Demo of NiMo Lesson 3-2 Exercises 1,2,3,4,5,6 (Arithmetic Operators with Program ‘Convert.cpp’) Q&A about operators and slides of precedence rules from Chapter 3 Lab Demo Exercise Assignment (Due Feb 16) Practice Questions (Not Due). - PowerPoint PPT Presentation

Citation preview

Page 1: Session-7 CSIT 121  Spring 2006

11

Session-7 CSIT 121 Session-7 CSIT 121 Spring 2006Spring 2006

• Lab Demo of NiMo• Lesson 3-2 Exercises 1,2,3,4,5,6

(Arithmetic Operators with Program ‘Convert.cpp’)

• Q&A about operators and slides of precedence rules from Chapter 3

• Lab Demo Exercise Assignment – (Due Feb 16)

• Practice Questions (Not Due)

Page 2: Session-7 CSIT 121  Spring 2006

22

Division and Precedence RulesDivision and Precedence Rules

• How can we obtain only the remainder of a division operation?

• What data type of dividend and divisor would result in only the quotient after the division?

• If two operators are of equal precedence in an expression, which one is applied first?

• How can we change the default precedence of operators?

Page 3: Session-7 CSIT 121  Spring 2006

33

Lab Exercise (Demo Due Feb 16)Lab Exercise (Demo Due Feb 16)

• Write a program that asks the user to input a number between 1 and 5,000. If the user enters a number greater than 5,000, the program terminates with an appropriate message. If the number is valid, the program displays the thousands digit, hundreds digit, tens digit and ones digit of the number, each on a separate line. Finally, the program displays the original number reversed on one line. See example interactions on next two slides.

Page 4: Session-7 CSIT 121  Spring 2006

44

Sample Run-1 of Number Sample Run-1 of Number Separator ProgramSeparator Program

• Please enter a number between 1 and 5000: 3927

• Here are the digits one by one• 3• 9• 2• 7• Here is the number in reverse 7293• Press any key to continue

Page 5: Session-7 CSIT 121  Spring 2006

55

Sample Run-2Sample Run-2

• Please enter a number between 1 and 5000: 21• Here are the digits one by one• 0• 0• 2• 1• Here is the number in reverse 12• Press any key to continue

Page 6: Session-7 CSIT 121  Spring 2006

66

Practice Questions (Not Practice Questions (Not Graded)Graded)

• Exam Prep Exercise 5 Page 134 4th ed.

• Exam Prep Exercise 7 Page 134 4th ed.

• Programming Problem 1 Page 137 4th ed.