1,105,208 Community Members

Solving the problem of C and C++

Member Avatar
gazzy1
Light Poster
38 posts since Jun 2010
Reputation Points: -2 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

I have no idea how it will be created plz help me as long experience I have forgotten due to my illness.

Write a program to determine if the digits in a three digit number are all odd, all even, or mixed odd and even. Your program should prompt the user to input a three digit number. If the digits in the three number are all odd, write “ the number contains all odd digits”, if the digits are all even, write “the number contains all even digits”, if the number contains both even and add digits then print : the number contains both even and odd digits”. Use integer division and modulus operator to access digits in the number.

Member Avatar
zeroliken
Nearly a Posting Virtuoso
1,222 posts since Nov 2011
Reputation Points: 79 [?]
Q&As Helped to Solve: 216 [?]
Skill Endorsements: 15 [?]
 
0
 

divide the number by ten and hundred to get the value of each digit then
use a loop that checks if the digit is odd or even by using the modulo operator (if the number is divisible by 2), if the remainder is 0 then it's even else odd

Member Avatar
gazzy1
Light Poster
38 posts since Jun 2010
Reputation Points: -2 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

plz send me the complete code if u have time plz

Member Avatar
zeroliken
Nearly a Posting Virtuoso
1,222 posts since Nov 2011
Reputation Points: 79 [?]
Q&As Helped to Solve: 216 [?]
Skill Endorsements: 15 [?]
 
0
 

Daniweb Rule:
Do provide evidence of having done some work yourself if posting questions from school or work assignments

plus this isn't as hard as you think, shouldn't take you long if your search the web for examples, which part are you having problem with?
let's start with the first step:
divide the number by 100 then store the value in another variable to get the first digit
divide the number by 10 then store the value in another variable to get the second digit
as for the third digit located in the ones place you could multiply the first 2 by their respective place value, add them, then subtract it from the main number to get the one's place digit

Member Avatar
Ancient Dragon
Achieved Level 70
27,571 posts since Aug 2005
Reputation Points: 5,231 [?]
Q&As Helped to Solve: 3,028 [?]
Skill Endorsements: 115 [?]
Team Colleague
Featured
Sponsor
 
0
 

Sorry to hear about your illness, that happens to everyone. When that happens to you after you start working do you really expect other people to do all your work for you?? It ain't going to happen. If you don't remember how to do it then you need to refresh your memory by re-reading your text book and studying the examples in it. Or just drop the course and take it again next semester.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: