Question: write in C++. Write a function string evenDigits(int x); that returns a string object which retains only the even digits (0, 2, 4, 6, 8)

write in C++.

Write a function string evenDigits(int x); that returns a string object which retains only the even digits (0, 2, 4, 6, 8) of the parameter integer x. For example, the function call evenDigits (2964743) should return a string object with contents "2644"; evenDigits (-689) should return a string object with contents "68";evenDigits (o) should return a string object with contents "O". Note that if x contain odd digits only (e.g., 99571), the the function should return an empty string.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!