URGENT!
Hello, I am having trouble trying to figure out how I need to do this problem for...
![Computers and Technology](/tpl/images/cats/informatica.png)
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.
![answer](/tpl/images/cats/otvet.png)
Answers: 1
Other questions on the subject: Computers and Technology
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 22.06.2019 17:30, Samsonb
Working on this program in python 3.7: a year in the modern gregorian calendar consists of 365 days. in reality, the earth takes longer to rotate around the sun. to account for the difference in time, every 4 years, a leap year takes place. a leap year is when a year has 366 days: an extra day, february 29th. the requirements for a given year to be a leap year are: 1) the year must be divisible by 42) if the year is a century year (1700, 1800, the year must be evenly divisible by 400some example leap years are 1600, 1712, and 2016.write a program that takes in a year and determines whether that year is a leap year. ex: if the input is 1712, the output is: 1712 is a leap year. ex: if the input is 1913, the output is: 1913 is not a leap year. your program must define and call the function isleapyear(useryear). the function should return true if the input year is a leap year and false otherwise.
Answers: 1
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 22.06.2019 20:00, BreadOfTheBear
What statement best describes operating systems? it’s possible for modern computers to function without operating systems. most operating systems are free or very inexpensive. operating systems are managed by the computer’s microprocessor (cpu). operating systems manage the computer’s random access memory (ram).
Answers: 1
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 00:00, eguzmandpandoracom
How do we use the sumif formula (when dealing with different formats) ?
Answers: 1
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 19:50, Aprillove7939
Which feature is selected to practice and save the timing of a presentation
Answers: 1
Do you know the correct answer?
Questions in other subjects:
![Konu](/tpl/images/cats/mat.png)
Mathematics, 18.08.2021 02:30
![Konu](/tpl/images/cats/himiya.png)
![Konu](/tpl/images/cats/mat.png)
Mathematics, 18.08.2021 02:30
![Konu](/tpl/images/cats/istoriya.png)
![Konu](/tpl/images/cats/mat.png)
![Konu](/tpl/images/cats/himiya.png)
![Konu](/tpl/images/cats/ekonomika.png)
![Konu](/tpl/images/cats/mat.png)
Mathematics, 18.08.2021 02:40
![Konu](/tpl/images/cats/istoriya.png)