Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ program Given a non-negative integer num, add all the digits and determine if this sum is prime. A prime is a natural number (greater

C++ program

Given a non-negative integer num, add all the digits and determine if this sum is prime. A prime is a natural number (greater that 1) that have no factors other than one and itself. If the result is no (The sum of digits is NOT prime), output the largest prime number that is less than the input number. For example: Input a number 38, the result is Yes (Prime). Input a number 1998, The result is No (Not Prime). The largest prime number that is less than the input number is 1997. Input a number 15, The result is No (Not Prime). The largest prime number that is less than the input number is 13.

Note: 1. The data type of input variable num is int.

2. The input integer may have any number of digits.

3. You can assume that the input is a non-negative integer and is greater than 1.

4.It is NOT necessary to include any other library, except

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_2

Step: 3

blur-text-image_3

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

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

Contrast intelligence and emotional intelligence.

Answered: 1 week ago

Question

If sin' (1-x) - 2 sin x = I 2 then Find the value of x.

Answered: 1 week ago