As matter of fact, the
Quote:
f ((pin >= 0) && (pin <= 9))
is plain wrong (other than useless).
It looks you're allowed to use
C++
string
s. If you are also allowed to use modern
C++
features then try:
#include <iostream>
#include <array>
using namespace std;
int main()
{
using Code = array<char, 4>;
const Code pwd{'a','f','g','t'};
Code pin;
cout << "please enter the pin\n";
for (auto & c : pin)
cin >> c;
if ( pwd == pin)
cout << "that's OK\n";
else
cout << "sorry, no luck\n";
}