Não entendo porque o switch deste programa não está funcionando, quando escolho a opção entra no system ("pause");
#include <stdio.h>
#include <stdlib.h>
void menu();
void limpartela();
void sair();
void enter();
void denter();
void dentertabula();
void tabula();
void soma();
void subt();
void multi();
void divi();
char opc;
int main()
{
menu();
system ("pause");
return 0;
}
void limpartela()
{
system("cls");
}
void sair()
{
exit(1);
}
void enter()
{
printf("\n");
}
void denter()
{
printf("\n\n");
}
void dentertabula()
{
printf("\n\n\t");
}
void tabula()
{
printf("\t");
}
void menu()
{
limpartela();
int esc;
printf("Que calculo voce quer fazer?");
dentertabula();
printf("1 - Soma");
enter();
tabula();
printf("2 - Subtracao");
enter();
tabula();
printf("3 - Multiplicacao");
enter();
tabula();
printf("4 - Divisao");
enter();
tabula();
printf("5 - Sair");
enter();
printf("Opcao: ");
scanf("%d", &esc);
getchar();
switch (esc)
{
case 1:
void soma();
break;
case 2:
void subt();
break;
case 3:
void multi();
break;
case 4:
void divi();
break;
case 5:
void sair();
break;
default:
menu();
}
}
void soma(void)
{
limpartela();
int a, b, soma;
printf("Digite os valores da soma:");
enter();
tabula();
printf("valor: ");
scanf("%d", &a);
tabula();
printf("+");
tabula();
printf("valor: ");
scanf("%d", &b);
soma = a + b;
tabula();
printf("%d + %d = %d", a, b, soma);
printf("\n\nResultado: %d", soma);
printf("Resultado: %d", soma);
printf("Deseja voltar ao menu? (s/n)");
scanf("%c", &opc);
getchar();
if (opc=='s')
{
menu();
}else{
denter();
printf("Obrigado! ");
}
}
void subt()
{
limpartela();
int c, d, sub;
printf("Digite os valores da subtracao:");
enter();
tabula();
printf("valor: ");
scanf("%d", &c);
tabula();
printf("-");
tabula();
printf("valor: ");
scanf("%d", &d);
sub = c - d;
tabula();
printf("%d - %d = %d", c, d, sub);
printf("Resultado: %d", sub);
printf("Deseja voltar ao menu? (s/n)");
scanf("%c", &opc);
getchar();
if (opc=='s')
{
menu();
}else{
denter();
printf("Obrigado! ");
}
}
void multi()
{
limpartela();
int e, f, mul;
printf("Digite os valores da multiplicacao:");
enter();
tabula();
printf("valor: ");
scanf("%d", &e);
tabula();
printf("*");
tabula();
printf("valor: ");
scanf("%d", &f);
mul = e * f;
tabula();
printf("%d * %d = %d", e, f, mul);
printf("Resultado: %d", mul);
printf("Deseja voltar ao menu? (s/n)");
scanf("%c", &opc);
getchar();
if (opc=='s')
{
menu();
}else{
denter();
printf("Obrigado! ");
}
}
void divi()
{
limpartela();
int g, h, div;
printf("Digite os valores da divisao:");
enter();
tabula();
printf("valor: ");
scanf("%d", &g);
tabula();
printf("/");
tabula();
printf("valor: ");
scanf("%d", &h);
div = g / h;
tabula();
printf("%d / %d = %d", g, h, div);
printf("Resultado: %d", div);
printf("Deseja voltar ao menu? (s/n)");
scanf("%c", &opc);
getchar();
if (opc=='s')
{
menu();
}else{
denter();
printf("Obrigado! ");
}
}