Set hasDigit to true if the 3-character passCode contains a digit.
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main() {
bool hasDigit;
string passCode;
hasDigit = false;
passCode = "abc";
/ Your solution goes here /
if (hasDigit) {
cout << "Has a digit." << endl;
}
else {
cout << "Has no digit." << endl;
}
return 0;
}
Answer:
if (isdigit(passCode.at(0)) || isdigit(passCode.at(1)) || isdigit(passCode.at(2)))
{
hasDigit = true;
}
Learn More :
Top 1000 Questions
- A Omar ____ ir de compras.
- A ti y a mí ____ el baile.
- A Marcela ____ los libros.
- A mis amigos ____ los museos.
- A ella ____ el ciclismo.
- A ustedes ____ el béisbol.
- A ti ____ las películas.
- A usted ____ los viajes.
- A mí ____ las revistas.
- A Jorge y a Luis ____ los perros.
- A nosotros ____ las vacaciones.
- A usted ____ jugar al tenis.
- A mi esposo y a mí ____ dormír.
- A Alberto ____ dibujar y pintar.
- A todos ____ opinar.
- A Pili ____ los sombreros.
- A nosotras ____ cantar.
- A ustedes ____ leer.
- A ti ____ correr y patinar.
- A ellos ____ los aviones.
- A mis padres ____ caminar.
- ¿Buscaron ustedes a alguien en la playa?
- ¿Te gusta alguno de estos trajes?
- A mí ____ bailar.
- ¿Quieres comer algo ahora?