it's not homework
It's close enough.
i have a final exam and this question was in one of the final exam sample
i just want to know how to solve it.
I have an idea, how about you try to solve it and we'll help out when you hit any stumbling blocks. Just having someone else solve the problem for you doesn't teach you jack about how to solve problems.
deceptikon
Challenge Accepted
3,452 posts since Jan 2012
Reputation Points: 822
Solved Threads: 473
Skill Endorsements: 57
First, as a minor point that you should be aware of, you should never use void as the return type of the main() function. While earlier versions of the C standard allowed it, it is non-portable; in C++, it is strictly forbidden. Use int main() in the future, please.
Also, please make sure your code is suitably indented to make reading easier. While the formatting conventions may make the code look like some sort of weird poetry, they make the code far easier to read, and with practice become quite natural.
As for how you would allow for multiple users' PINs, the answer lies with arrays, and a loop on the test for whether the PIN matches or not. If you have covered arrays at all yet, this should become clear with a little thought.
I would add that it would make far more sense to use a 4-character array for the PIN, and a test to make sure that the input is numeric (using the function isdigit() from the <cctype> library). The reason for this should become apparent if you consider the case of PINs starting with a zero ('0') character.
Schol-R-LEA
Veteran Poster
1,038 posts since Oct 2010
Reputation Points: 447
Solved Threads: 166
Skill Endorsements: 11
That, unfortunately, is one thing we won't do for you here; you have to write the program on your own, we'll help you debug it but we won't write it for you
Schol-R-LEA
Veteran Poster
1,038 posts since Oct 2010
Reputation Points: 447
Solved Threads: 166
Skill Endorsements: 11