It certainly does happen too often but face it, it's impossible to police the forums on that level. Plus, it's just human nature to try and help people when you can. Especially if it represents an opportunity to show off your newly learned skills. At least timmy already understands (@ only 14 posts) that it's hurting more than helping to spoon-feed answers.
This does not mean that you can't help. Just help in a way that makes the person think for themselves so they develop the critical thinking skills required to be a good programmer. bl4ckb3rry's response was useless at anything other than helping another person cheat. No explanations, not even a single comment in the code. What was the point???
I can try to describe how you could build it, because they'll... crucify me if I post code...
1. include <math.h> or <cmath>, either one works.
2. have a function you may call CountDigits that take an int, let's call it Number.
3. have a variable called _at
4. have a while loop that checks the equation Number / 10^_at > 1 and increase _at by 1 until the equation reaches a value below 1 and thus break the loop.
5. return _at
in the main function (int main()) write cout << CountDigits(your number of choise) << endl;
This is a bit vague, but it's perhaps as far as I can go ... or too far?
A programmer is an engineer, once you hear your assignement or task, your brain should think of ways to solve it, not strictly in code though. How would you do it by math given that you can't count the digits? Or how can you make your program count the digits in the numbers as a string?
GisleAune the answer to this problem has already been posted. We've also already told him that he just needs to use the string libraries length() function.
He's now trying to solve this: "* write a function named "digit_name"that takes an integer argument in the range from 1 to 9 , inclusive , and prints the English name for that integer on the computer screen . The function should nor return a value . if the argument is not in the required range, then the function should print "digit error" . Thus, for example , the statement digit_name(7); should print seven on the screen ; the statement digit_name(0); should print digit error on the screen .. ???????"
For the second time I recommend you research switch statements.
"Help" does not include solving the problem FOR them. "Help" entails giving them the instruction they require to complete the task themselves. He won't gain anything by having us give him the code for all his homework, and it will just perpetuate the steady stream of bad programmers coming out of colleges these days.