subject

URGENT!

Hello, I am having trouble trying to figure out how I need to do this problem for my C++ class.

The assignment is asking me to write a program that will count the number of EVEN digits in a given number.

This is my first Programming class so please bare with me.

My current code is below:

int countEven (int n);

int even_count = 0;

int n;

while (n > 0)

{

int rem = n % 10;

if (rem % 2 == 0)

even_count++;

}

if (even_count % 2 == 0)

even_count++;

std::cout << "Even Digits Program\n";

std::cout << "Enter a number greater than 0.\n";

std::cin >> n;

std::cout << "This number has " << even_count << " even digit(s).";

The problem I am having is that it keeps returning 1 even digit for any number I input.

If you could help me with this I would greatly appreciate it.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 05:30
The total revenues for a company are $150,223 and the total expenses were 125,766. if you are calculating the net income, which of these spreadsheets would you use? insert a spreadsheet with $150,223 in cell b2 and 125, 766 in cell b3. enter a formula =b2-b3. the formula should be showing in the formula bar. insert a spreadsheet with $150,223 in cell b2 and 125, 766 in cell b3. enter a formula =b2+b3. the formula should be showing in the formula bar. insert a spreadsheet with $150,223 in cell b2 and 125, 766 in cell b3. enter a formula =b2/b3. the formula should be showing in the formula bar. insert a spreadsheet with $150,223 in cell b2 and 125, 766 in cell b3. enter a formula =b2*b3. the formula should be showing in the formula bar.
Answers: 3
question
Computers and Technology, 22.06.2019 16:30
Primary tech skills are skills that are necessary for success in online education
Answers: 3
question
Computers and Technology, 22.06.2019 20:00
Which location-sharing service offers items for users as a gaming component and also allows them to collectively link their check-ins to publish a trip? a. whrrl b. buzzd c. foursquare (this option is wrong i already tried) d. gowalla for plato
Answers: 2
question
Computers and Technology, 23.06.2019 01:30
Which tab is used to change the theme of a photo album slide show? a. design b. view c. transitions d. home
Answers: 1
You know the right answer?
URGENT!

Hello, I am having trouble trying to figure out how I need to do this problem for...
Questions
question
Biology, 21.03.2020 05:48
question
Chemistry, 21.03.2020 05:50
Questions on the website: 13722367