Do-while repetitive structure in C language [duplicated]

0

I'm having problems with this Do While repeating structure. I need to ask the user for a whole number and make the multiplication table of that number from 1 to 10, then ask if you want to consult another table. If you press the s key, you do it again, if you press n it ends and you give a thank you message. I would like you to help me find the error, I think it's syntax. Thanks in advance!

This is the code:

#include <stdio.h>
#include <conio.h>
int main() {
    int i, num, producto;
    char seguir;
    do {
        printf("\nIntroduzca un número entero: ");
        scanf("%i", &num);
        printf("\nLa tabla de multiplicar del %i es:\n\n", num);
        for (i=1;i<=10;i++)
            {
            producto=num*i;
            printf("%i * %i = %i\n", i, num, producto);
            }
        printf("\n¿Desea ver otra tabla (s/n)?: ");
        scanf("%c", &seguir);
    } while (seguir='s');
    printf("\nHa finalizado el programa.\n");
    printf("¡Gracias por utilizarlo!");
    return 0;
}
    
asked by NéstorJ 11.04.2018 в 14:13
source

1 answer

2
  

Yes, I did not add the == but I compiled and executed it and it does not even allow me to enter the keyboard input to ask if I want to continue the program or not

The problem is that, to read a character, scanf does not eliminate the previous line break ... try this:

scanf(" %c", &seguir);
//     ^ un espacio
    
answered by 11.04.2018 / 14:32
source