I am creating a code that reads the number entered by the user and, if it is from 1 to 10, he / she performs the table, presenting value by value on the screen, and allows the user to choose whether to check another table.
The first time, it runs smoothly. However, if the user chooses to make a new query, the program requests the new number but does not display the new values, getting locked in the conditional loop.
Follow the logic used by me:
static void Main(string[] args)
{
int cont = 1, valor, auxiliar, continuar = 1;
while (continuar == 1)
{
Console.WriteLine("Digite um numero de 1 a 10: ");
valor = int.Parse(Console.ReadLine());
if (valor <= 10)
{
while (cont <= 10)
{
auxiliar = valor * cont;
Console.WriteLine(valor + " X " + cont + " = " + auxiliar);
cont++;
}
Console.WriteLine("Deseja verificar a tabuada de algum outro número? Digite 1 para SIM ou 2 para NAO");
continuar = int.Parse(Console.ReadLine());
Console.ReadKey();
}
else
{
Console.WriteLine("Número inválido! ");
}
}
}