Answer to Question #231830 in C++ for Knight_manakal

Question #231830
Write statements to validate the number given below is a 4-digit integer and then to print the digits divisible by 2. int number38459
1
Expert's answer
2021-09-01T23:56:44-0400
#include <iostream>




using namespace std;




void printDigitsDivisibleBy2(int number);


int main(){


	int number;
	cout << "Enter integer number: ";
	cin>>number;
	printDigitsDivisibleBy2(number);




	system("pause");
	return 0;
}


void printDigitsDivisibleBy2(int number){
	
	while(number>0){
		int digit = number % 10;
		number = number/10;
		if (digit%2==0){
			cout<<digit<<" is divisible by 2.\n";
		}	
	}
} 




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS