Write a function createPassword() with no return value to randomly select 8 capital letters from the alphabet. The function receives the address of the first characters of the password string as parameter.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter10: Pointers
Section: Chapter Questions
Problem 1PP
icon
Related questions
Question

(10)

Question 2.2

NOTE: Pointers must be used to solve the following problem. You will 8 marks if pointers are not used, even if

the solution is correct.

Write a function createPassword() with no return value to randomly select 8 capital letters from the alphabet.

The function receives the address of the first characters of the password string as parameter.

Hint: Declare a characters string that contains all the capital letters of the alphabet and use the index values

of the characters in the string for random selection of characters, e.g.

5

char alpha [27] = “ABCDEFGHIJKLMNOPQRSTUVWXYZ”;

char *pAlpha = alpha;

Expert Solution
Step 1

In C++, to generate a random number rand() function is used.  If we set the random number generator with the system time then it will generate the random numbers every time we run the program. To generate the password randomly, we use rand () function to assign alphabet string with random index number to the password.

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr