URGENT!
Hello, I am having trouble trying to figure out how I need to do this problem for...
Computers and Technology, 24.02.2020 05:18 jewlbug4358
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.
Answers: 1
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
Computers and Technology, 22.06.2019 20:00
What is used to analyze and summarize your data without graphical support
Answers: 1
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
Arts, 10.06.2020 09:57
Mathematics, 10.06.2020 09:57
Biology, 10.06.2020 09:57
Mathematics, 10.06.2020 09:57
Mathematics, 10.06.2020 09:57
Mathematics, 10.06.2020 09:57