Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

P2 (30 points) - Array Step 1 (5 points): Write a function isPrime() that gets an integer number and returns true if the number is

P2 (30 points) - Array

Step 1 (5 points): Write a function isPrime() that gets an integer number and returns true if the number is prime and returns false if the number is not prime.

Hint: A number is prime if it is divisible by only 1 and itself.

Step 2 (15 points): Write a function that gets an array and counts and returns the number of elements of the array that are prime (using the function in step 1).

Step 3(10 points): In your main(), create an array of size 100 and initialize it with the first 100 odd numbers, starting 1 (that is 1, 3, 5, ...). Use the function in step 2 to count the number of prime numbers in the array.

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Please discuss the Drive Theory (Motivation) in Management

Answered: 1 week ago