#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main()
{
int var1, var2, Q, R, decisao = 2;
while(decisao == 2){
printf("Dividindo dois numeros\n\n");
printf("Digite o dividendo: ");
scanf("%d", &var1);
printf("Digite o divisor: ");
scanf("%d", &var2);
Q = var1 / var2;
R = var1 % var2;
printf("Resultado: %d\n", Q);
printf("Resto: %d\n", R);
printf("\nDeseja encerrar o programa?[1] para sim e [2] para nao..\nOpcao: ");
scanf("%d", &decisao);
}
printf("\nPrograma finalizado");
system("PAUSE>>NULL");
return 0;
}
Notice that I added a while, that is, as long as the number the user types is equal to 2, the replay will continue.
Also when declaring the variable "continue" was assigned the value 2
It would be better to do the repetition this way:
char ch = 'S';
while(ch == 'S' || ch == 's'){
**FAÇA**
printf("Para continuar pressione "S" para sair digite qualquer outra tecla");
ch = getch();
}
To use getch (); you would need to include the conio.h