Jump to content

programa não funciona


migg
 Share

Recommended Posts

O problema é que ao fazer a opção de inserir data de um teste ao inserir o dia tudo bem mas quando eu clico enter para inserir o mês aparece uma janela a dizer que o programa deixou de funcionar como resolvo isso

#include <stdlib.h>
#include <stdio.h>

int main()
{
   int opc, numtest, opcdois, ld, lm, md, mm, fd, fm, id, im, hd, hm, gd, gm, ed, em, cd, cm, mod, mom;
   float media, a, b, c, d;

   do {
printf("          Clique 1 para fazer a media dos teste___________________nnn");
printf("n              Clique 2 para ver a data dos testes________________________n");
scanf("%d", &opc);
   } while ((opc < 1) || (opc > 2));

   switch (opc)
   {
   case 1:
printf("nnQuantos testes tives-te?nn");
printf("1nn");
printf("2nn");
printf("3nn");
printf("4nn");
scanf("%d", &numtest);

if (numtest == 1)
{
    printf("Insira a nota dos testes nn");
    scanf("%f", &a);

    media = a / 1;

    printf("tnA media e de:%f", media);
}

if (numtest == 2)
{
    printf("Insira a nota dos testes nn");
    scanf("%f", &a);
    scanf("%f", &b);

    media = (a + b) / 2;

    printf("tnA media e de:%f ", media);
}
if (numtest == 3)
{
    printf("Insira a nota dos testes nn");
    scanf("%f", &a);
    scanf("%f", &b);
    scanf("%f", &c);

    media = (a + b + c) / 3;

    printf("tnA media e de:%f ", media);
}
if (numtest == 4)
{
    printf("Insira a nota dos testes nn");
    scanf("%f", &a);
    scanf("%f", &b);
    scanf("%f", &c);
    scanf("%f", &d);

    media = (a + b + c + d) / 4;

    printf("tnA media e de:%f ", media);
}
break;

   case 2:
do
{
    printf("------Inserir data de um teste-----1nn");
    printf("------Ver a tabela de testes-----2nn");
    scanf("%d", &opcdois);
}
while ((opcdois < 1) || (opcdois > 2));

switch (opcdois)
{
case 1:
    printf("nnnLingua Portuguesa                                nn");
    scanf("%d", ld);
    scanf("%d", lm);
    printf("Matematica                                             nn");
    scanf("%d", md);
    scanf("%d", mm);
    printf("Moral                                                  nn");
    scanf("%d", mod);
    scanf("%d", mom);
    printf("Fisico quimica                                         nn");
    scanf("%d", fd);
    scanf("%d", fm);
    printf("Ciencias Naturais                                      nn");
    scanf("%d", cd);
    scanf("%d", cm);
    printf("Educacao Fisica                                        nn");
    scanf("%d", ed);
    scanf("%d", em);
    printf("Geografia                                              nn");
    scanf("%d", gd);
    scanf("%d", gm);
    printf("Historia                                               nn");
    scanf("%d", hd);
    scanf("%d", hm);
    printf("Ingles                                                 nn");
    scanf("%d", id);
    scanf("%d", im);
    printf("Frances                                                nn");
    scanf("%d", fd);
    scanf("%d", fm);
    break;

case 2:
    printf("nnn    ________________________Dia_____Mes_______________________________");
    printf("nnnLingua Portuguesa              %d         %d         nn", ld, lm);
    printf("Matematica                           %d         %d         nn", md, mm);
    printf("Moral                                %d         %d         nn", mod, mom);
    printf("Fisico quimica                       %d         %d         nn", fd, fm);
    printf("Ciencias Naturais                    %d         %d         nn", cd, cm);
    printf("Educacao Fisica                      %d         %d         nn", ed, em);
    printf("Geografia                            %d         %d         nn", gd, gm);
    printf("Historia                             %d         %d         nn", hd, hm);
    printf("Ingles                               %d         %d         nn", id, im);
    printf("Frances                              %d         %d         nn", fd, fm);
    printf("    ____________________________________________________________nn");
    break;
}
   }
   system("Pause");
   return (0);
}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.