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, 21.06.2019 17:30
Who invented the tv .hint it was 2 people
Answers: 1
question
Computers and Technology, 22.06.2019 11:00
Which are examples of note-taking tools? check all that recording devices sticky notes digital highlighters paper flags highlighting pens digital displays digital flags
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
What is used to analyze and summarize your data without graphical support
Answers: 1
question
Computers and Technology, 22.06.2019 21:30
Im doing this last minute and literally none of my neighbors or people that my dad works with use excel so if anyone could me make up an example
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
Arts, 10.06.2020 09:57
question
Mathematics, 10.06.2020 09:57
question
Mathematics, 10.06.2020 09:57
Questions on the website: 13722361