Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions