1 / 6

Lab Session-3 CSIT 121 Spring’05

Lab Session-3 CSIT 121 Spring’05. Division rules Operator precedence rules Lab Exercise. Division 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?

billien
Download Presentation

Lab Session-3 CSIT 121 Spring’05

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab Session-3 CSIT 121 Spring’05 • Division rules • Operator precedence rules • Lab Exercise

  2. Division 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?

  3. 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.

  4. Sample Run-1 of Number Separator 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

  5. 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

  6. Practice Questions (Not Graded) • Exam Preparation Exercise 5 Page 134 4th ed. • Exam Preparation Exercise 7 Page 134 4th ed. • Programming Problem 1 Page 137 4th ed.

More Related