Question: (2) (a) Write the definition for function named twoRightDigits that takes a single integer argument and returns the value of the two rightmost digits of

 (2) (a) Write the definition for function named twoRightDigits that takes

(2) (a) Write the definition for function named twoRightDigits that takes a single integer argument and returns the value of the two rightmost digits of the integer. For example, if the argument is 2014, the function should return 14; if it is 12345, it should return 45; if it is 107, it should return 7; if it is 1, it should return 1. However, if the integer argument is zero or negative, the function should return 0. (b) Write a main program that asks a user to input a number, and validates that the number is positive. If it is not, the program should repeatedly ask the user to input a positive vale until the user does so. If the input value is positive, the program should call the function from part (a) and then print out the returned value. Then the program should ask if the user wishes to input another number (y). If they do the program should repeat the process above, continuing until the user indicates they do not wish to enter another number

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!