Switch command does not work and has no errors

I am trying to solve the following exercise: to elaborate an algorithm that assists in the control of a cattle farm that has a total of 2000 head of cattle. The database consists of a set of structures (records) containing the following fields for each head of cattle:

* code: cattle head Code

• milk: number of litres of milk produced per week;

* food: amount of food eaten per week - in kilograms;

* nasc: date of birth-month and Year;

* if Kill ‘ ' N " (no) or ‘S’ (yes).

The nasc field. it is of type struct data which in turn has two fields:

• month

* Year

Elaborate functions for:

A) read the database (code, milk, food, nasc.month and birth.year), stored in a vector of structures.

B) fill in the field slaughter, considering that the head of cattle will go to slaughter if:

• be over 5 years old, or;

* produce less than 40 litres of milk per week, or

* produce between 50 and 70 liters of milk per week and eat more than 50 kilograms of food per day.

C) create the options menu for:

C1.Return the total amount of milk produced per week on the farm.

C2. Return the total amount of food consumed per week on the farm.

C3.Return the total amount of milk that will be produced by week on the farm, after the slaughter.

C4. Return the total amount of food that will be consumed per week on the farm, after slaughter

C5. Return number of cattle heads that went to slaughter.

C6. Quit the show.

However, I am having problems with the Switch command, my code is not displaying any message, either error or warning.

Below is the Code:

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

struct nascimento
{
    int mes;
    int ano;
};

struct registro
{
    int codigo;
    int leite;
    int alimento;
    char abate[2];
    struct nascimento nasc;
};

struct registro gadovet[2];

void registrar_gado(struct registro gadovet[5];)
{
    int i;
    for (i = 0;i < 2; i++)//registro dos 2000 gado
    {
        printf("Digite o código do gado: ");
        scanf("%d", &gadovet[i].codigo);
        printf("Digite a quantidade de leite que o gado fornece por semana - em litros: ");
        scanf("%d", &gadovet[i].leite);
        printf("Digite a quantidade de alimento ingerida por semana - em quilos: ");
        scanf("%d", &gadovet[i].alimento);
        printf("Digite a data de nascimento do gado\n");
        printf("Mês: ");
        scanf("%d", &gadovet[i].nasc.mes);
        printf("Ano: ");
        scanf("%d", &gadovet[i].nasc.ano);

        //verificação de abate
        if (gadovet[i].leite >= 50 && gadovet[i].leite <= 70 && gadovet[i].alimento > 50)
        {
            if (gadovet[i].nasc.ano < 2013 || gadovet[i].leite < 40)
            {
                strcpy (gadovet[i].abate, "S");
            }
            else
            {
                strcpy (gadovet[i].abate, "N");
            }
        }
        if (gadovet[i].nasc.ano > 2013 || gadovet[i].leite > 40)
            {
                strcpy (gadovet[i].abate, "N");
            }
    }
}

int main()
{
    setlocale(LC_ALL,"Portuguese");
    int i, x = 0, n = 0, abate = 0;
    char sim[2] = {"S"};
    char nao[2] = {"N"};

    registrar_gado(gadovet[2]);

    do//Menu
    {
        printf("Escolha uma das opções:");
        printf("\n1 - Verificar a quantidade total de leite produzida por semana na fazenda.");
        printf("\n2 - Verificar a quantidade total de alimento consumido por semana na fazenda.");
        printf("\n3 - Verificar a quantidade total de leite que vai ser produzido por semana na fazenda, após o abate.");
        printf("\n4 - Verificar a quantidade total de alimento que vai ser consumido por semana na fazenda, após o abate.");
        printf("\n5 - Verificar o número de cabeças de gado que iram para o abate.\n\n");
        scanf("%d", &n);

    }while(n = 0);

    switch (n)
    {
        case 1://Leite por semana
            for (i = 0;i < 2; i++)
            {
                x = x + gadovet[i].leite;
            }
            printf("A quantidade de leite que o todo o gado oferece por semana é de %d Litros.", x);
            break;
        case 2://Alimento por semana
            for (i = 0;i < 2; i++)
            {
                x = x + gadovet[i].alimento;
            }
            printf("A quantidade de alimento que o todo o gado consome por semana é de %d Quilos.", x);
            break;
        case 3://Leite após abate
            for (i = 0;i < 2; i++)
            {
                if (!strcmp(gadovet[i].abate, nao))
                {
                    x = x + gadovet[i].leite;
                }
            }
            printf("A quantidade de Leite que será consumido por semana após o abate será de %d Litros.", x);
            break;
        case 4://Alimento após abate
            for (i = 0;i < 2; i++)
            {
                if (strcmp(gadovet[i].abate, nao))
                {
                    x = x + gadovet[i].alimento;
                }
            }
            printf("A quantidade de Alimento que será consumido por semana após o abate será de %d Quilos.", x);
            break;
        case 5://Cabeças pro abate
            for (i = 0;i < 2; i++)
            {
                if (!strcmp(gadovet[i].abate, sim))
                {
                    abate++;
                }
            }
            printf("A quantidade de cabeças que irão para o abate é de %d", abate);
            break;
        case 6:
            printf("Pressione qualquer tecla para sair...");
            system("Pause");
            break;
    }
}
Author: Costamilam, 2018-05-12

1 answers

In the line where the Command do...while is, the condition is like n = 0, try to exchange for n == 0.

 2
Author: Luan Dos Santos, 2018-05-12 01:05:04