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, 23.06.2019 00:30
Write the html code to make a link out of the text “all about puppies”. it should link to a pdf called “puppies.pdf” inside the “documents” folder. the pdf should open in a new window.
Answers: 2
question
Computers and Technology, 23.06.2019 02:00
Which demographic challenge is europe currently experiencing? a. an aging and decreasing population b. a baby boomc. an unequal distribution between males and females d. a large group of teenagers moving through the school system(i chose a but i'm unsure)
Answers: 1
question
Computers and Technology, 23.06.2019 09:00
Design a class tictactoe that: holds the following information about the game: two-dimensional array (3 by 3), and winner. add additional variables as needed. includes the functions to perform the various operations on objects. for example, function to print the board, getting the move, checking if move is valid, determining if there is a winner after each move. add additional operations as needed. includes constructor(s). write the functions of the class, and write a program that uses the class. the program should declare an object of type tictactoe. the program will create the board and store it in the array. the program will allow two players to play the tic-tac-toe game. after every valid move update the array, check if there is a winner. if there is no winner and no tie, then print the board again to continue.
Answers: 2
question
Computers and Technology, 23.06.2019 15:00
1. which of the following statements are true about routers and routing on the internet. choose two answers. a. protocols ensure that a single path between two computers is established before sending packets over it. b. routers are hierarchical and the "root" router is responsible for communicating to sub-routers the best paths for them to route internet traffic. c. a packet traveling between two computers on the internet may be rerouted many times along the way or even lost or "dropped". d. routers act independently and route packets as they see fit.
Answers: 2
You know the right answer?
URGENT!

Hello, I am having trouble trying to figure out how I need to do this problem for...
Questions