3
I am creating a code that reads the number typed by the user and, if it is from 1 to 10, it performs the tabulation, presenting value to value on the screen, besides allowing the user to choose whether to check some other tabular.
The first time, it goes smoothly. However, if the user chooses to make a new query, the program requests the new number but does not present the new values, being locked in the loop conditional.
Follows 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! ");
}
}
}
Would you know some place where I could learn this way used these days?
– Mateus Binatti
Nothing in central place, is to follow up, asking here. I’m thinking about writing a book about this.
– Maniero
It would be a great contribution to the community, for sure. However, could you explain to me this line: Writeline($"{value:D2} X {cont:D2} = {value * cont:D2}");
– Mateus Binatti
@Mateusbinatti here does not fit, ask a new question shows this and saying what did not understand.
– Maniero