Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started