Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, can you please write the code for ths question? I would like to note that you are only allowed to use one function for

Hi, can you please write the code for ths question? I would like to note that you are only allowed to use one function for the question and to keep in mind that the number generator has a 80% probability of being even, and 20% probability of being odd. For the number generator, please use the library and use function srand. Thanks!image text in transcribed

5. Random Palindrome: Write a function that takes integer N as a parameter. This function then generates N random digits (numbers between 0 and 9) using the computer time as the seed of the random number generator. The probability that a generated digit is even is 80% whereas the probability that a generated digit is odd is 20%. The function then concatenates the N randomly created digits to form one number. This function then checks if this number is a palindrome or not. (Hint: find the reverse of that number) Finally, the function prints out the number and says whether it is a palindrome or not. Examplel: Please enter the length of a number: 6 The concatenation of the 6 randomly generated numbers is: 258852 The number is a palindrome! Example2: Please enter the length of a number: 5 The concatenation of the 5 randomly generated numbers is: 86824 The number is a NOT a palindrome

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

Neo4j Data Modeling

Authors: Steve Hoberman ,David Fauth

1st Edition

1634621913, 978-1634621915

More Books

Students also viewed these Databases questions

Question

How do feedback and output differ?

Answered: 1 week ago

Question

b. Where did they come from?

Answered: 1 week ago

Question

c. What were the reasons for their move? Did they come voluntarily?

Answered: 1 week ago

Question

5. How do economic situations affect intergroup relations?

Answered: 1 week ago