Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. Thirty random numbers between 1 and 20 are entered into an array named nums and the to be searched is entered through the keyboard

image text in transcribed
4. Thirty random numbers between 1 and 20 are entered into an array named nums and the to be searched is entered through the keyboard by the user. Write a C program, rch.c, to display the generated random numbers and find the number to be d is present in the array and if it is present, display the number of times it appears in the array. The user can enter more than one number to be tested for search. The program terminates when the user enters a number that is less or equal to 0. A Sample interaction is 2 of 2 as follow numbers are: 4, 7,18,16,14,16, 7.13,10, 2 3, 8,11,20, 4, 7, 1, 7,13.17 12, 9, 8,10, 3,11, 3, 4, 8,16 Enter a number to be found (-0 for exit): 13 13 appears 2 time(s) Enter a number to be found (c0 for exit): 61 61 appears 0 time(s). Enter a number to be found ( to your code and then use rand () 20 + 1; 5. Any integer above 1 is either a prime number, or can be made by multiplying prime numbers together. For example: 16-2 x2x 2 x2- (24) 17 (171) 18 2 x 3 x3 (21) x (3*2) Write a C program, primeFactor.c, that asks the user for an integer number greater than 1 and displays the product of its prime factors. You program should implement at least the 1) int readNum ) to take a valid number (greater than 1) from the user. This function 2) bool IsPrime (int prime) to check a number is a prime. This function has one 3) ?nt findPrimeCount (int nun, int prime) to count the number of a given following 3 functions: has no input and returns a valid integer number entered by the user. integer variable as an input and a boolean variable as an output, named p flag. prime in the input number and display the result in the format of (prime freg). This function has two integer variables of num and prime as an input and retuns the updated. For example, calling tindPrimeCount (12, 2) displays (243) and returns the updated number of 3 A Sample interaction is as follow Enter a valid number P)I8 18 1x (21) x (33) Enter a valid number 1): g Invalid number Enter a valid number ): I9 19 1 x (191

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

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

If you were the reader, how would the message make you feel?

Answered: 1 week ago

Question

a. How will the leader be selected?

Answered: 1 week ago