-2
How do I if the user type a number other than 1 and 2 he asks you to terminate the program? n[1] for yes and [2] for no
#include <stdio.h>
#include <stdlib.h>
int main()
{
int N1, N2, Q, R, OP;
{
do
{
printf("DIVIDINDO DOIS NUMEROS: \n\n");
printf("Digite o dividendo: ");
scanf("%d", &N1);
printf("Digite o divisor: ");
scanf("%d", &N2);
Q = N1 / N2;
R = N1 % N2;
printf("\nResultado: %d\n", Q);
printf("Resto: %d\n", R);
printf("\n\nDeseja encerrar o programa?\n[1] para sim e [2] para nao.\n");
printf("\nOpcao: ");
scanf("%d", &OP);
printf("\n \n");
}
while (OP == 2);
if (OP >= 1)
{
exit(0);
}
system("PAUSE>>NULL");
return 0;
}
}
Possible duplicate of Avoid closing when typing different values of 1 and 2
– Woss
Not only is it duplicate but it’s the same user asking the same thing.
– StatelessDev