Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 1: Prime numbers Write a program to ask the user for integer n and then prints out if n is prime number. Use a

image text in transcribed
Exercise 1: Prime numbers Write a program to ask the user for integer n and then prints out if n is prime number. Use a return-value function, to be called prime (..).to test whether a given number is prime or not. The prototype st for this function is: atement bool prime(int) i Create another function called divisibleByTwo(..) check if the number is divisible by 2 or not (in case the number entered by the user is not prime). Note: A number n is prime if it only div Sample input / output: Enter a number to check if it is a prime or not: 11 ides evenly by 1 and n itself. 11 is a prime number Enter a number to check if it is a prime or not: 22 22 is NOT a prime 22 is dividable by2 Enter a number to check if it is a prime or not: 33 33 is NOT a prime 33 It's not dividable by 2

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

Database Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago