Question: 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
Get step-by-step solutions from verified subject matter experts
