C++ 1. Write a function named "acceptKey" that accepts an array of valid keys and its size. The method will read in a key from the user and check whether the user has entered one of the valid keys in the given array or not.  If not, it will allow the user to try up to 3 times. If the user was able to enter the expected key number within 3 tries, it will return true. Otherwise, it returns false and key value of 0. In addition, it also returned the key to the caller. For example, assuming the given valid key array contains {111, 222, 333, 444}  here are 2 different sets of runs:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

C++

1. Write a function named "acceptKey" that accepts an array of valid keys
and its size. The method will read in a key from the user
and check whether the user has entered one of the valid keys in the given array or not. 
If not, it will allow the user to try up to 3 times. If the user was able to enter the expected
key number within 3 tries, it will return true. Otherwise, it returns false and key value of 0.
In addition, it also returned the key to the caller.

For example, assuming the given valid key array contains {111, 222, 333, 444} 
here are 2 different sets of runs:

Please enter your key: 123
Please enter your key: 456
Please enter your key: 789
Return false and the returned key of 0

Please enter your key: 123
Please enter your key: 456
Please enter your key: 444
Return true and the returned key of 444

Requirement: please use only pointer notation. No array notation.
The use of pass-by-reference parameters is also not allowed. Use pointer parameters instead.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY