Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C function help, two functions 11. Define a function called phone_password (prototype below) that reads a phone number and verifies it corresponds to the phone

C function help, two functions

image text in transcribed

image text in transcribed

11. Define a function called phone_password (prototype below) that reads a phone number and verifies it corresponds to the phone number specified in the parameters. We define a phone number as a three digit integer, followed by a dash, followed by a four digits integer. For this problem: a. The function reads two integer values separated by a dash. The first integer represents the three digits of a phone number and the second the four digits; we are not using area code. b. The message "Enter phone in XXX-YYYY format:" will be displayed before reading the values. C. The function will compare the three digits and four digits values provided by the user against the three_digits and four_digits parameters. The function will keep asking for a phone as long as the values provided do not correspond to the parameters. Once they are the same, the function will end returning the number of attempts. Notice that the expected value represents one attempt. d. If the error_message parameter is true, the function will print the message "Invalid phone" after an invalid phone has been provided. e. You can assume users will provide valid data (integers) and a dash in between the integers. int phone_password (int three_digits, int four_digits, int error_message) Define a function called compute (prototype below) that computes either the sum or product of integers provided by the user. For this problem: The function reads integers values using scanf and the message "Enter value: "to read each value. The function will stop reading values when the user provides -1. If the sum_flag parameter is true, the function will compute and return the sum of the values; otherwise it will compute and return the product. If the print_flag parameter is true, the function will print the computed valued before returning the value. Use the message "Result: " followed by the computed valued. You can assume users will provide valid data integers) and the computation will not cause an overflow. Below we provided an example of using the function. Underlined text represents input and % the Unix prompt. Driver Output int main() { compute(0, 1); a.out Enter value: 4 Enter value: 5 Enter value: -1 Result: 20 return 0; int compute(int sum_flag, int print_flag)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions

Question

What is meant by organisational theory ?

Answered: 1 week ago

Question

What is meant by decentralisation of authority ?

Answered: 1 week ago

Question

Briefly explain the qualities of an able supervisor

Answered: 1 week ago

Question

Define policy making?

Answered: 1 week ago

Question

Define co-ordination?

Answered: 1 week ago