Jump to content

josedcastro

Membros
  • Contagem de Conteúdo

    7
  • Ingressou

  • Última visita

Community Answers

  1. josedcastro's publicar in Erro error: expected ';' before 'break' break; was marked as the answer   
    #include <stdio.h>
    #include <stdlib.h>
    // Main function
    int main() {
        // Initialize integer variable 'i'
        int i;
        // Do-while loop for user input
        do {
            // Prompt user to enter the flavor option
            printf("Digite a opção do sabor: \n");
            // Display flavor options
            printf("\t (1) Flocos \n");
            printf("\t (2) Morango \n");
            printf("\t (3) Leite Condensado \n");
            printf("\t (4) Ninho com Nutella \n");
            // Scan user input and store it in 'i'
            scanf("%d", &i);
            // Check if user input is out of bounds (less than 1 or greater than 4)
            if (i < 1 || i > 4) {
                // Display error message if input is invalid
                printf("Opção Inválida. Tente novamente.\n");
            }
        // Continue loop if user input is out of bounds
        } while ((i < 1) || (  i > 4) );
        // Switch statement to handle user input
        switch (i) {
            // Case 1: Flocos
            case 1:
                // Display user's choice
                printf("\t\t Sua escolha foi flocos");
                break;
            // Case 2: Morango
            case 2:
                // Display user's choice
                printf("\t\t Sua escolha foi Morango");
                break;
            // Case 3: Leite Condensado
            case 3:
                // Display user's choice
                printf("\t\t Sua escolha foi Leite Condensado");
                break;
            // Case 4: Ninho com Nutella
            case 4:
                // Display user's choice
                printf("\t\t Sua escolha foi Ninho com Nutella");
                break;
        }
        // Return 0 to indicate successful execution
        return 0;
    }
×
×
  • Create New...