Error compiling this simple program that shows the corresponding month

2

I'm trying to compile this program here in Code :: Blocks but I can not and can not understand why.

#include <iostream>
#include <string>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
using std::endl;
using std::cout;
using std::cin;
int main()

{
    int x = 0;
    cout << "Qual o mês atual Digite apenas um número de 0 a 12" <<  endl;
    cin >> x ;
    switch (x)
 {
     case 1 : cout << "Janeiro" << endl; break
     case 2 : cout << "Fevereiro" << endl; break
     case 3 : cout << "Março" << endl; break
     case 4 : cout << "Abril" << endl; break
     case 5 : cout << "Maio" << endl; break
     case 6 : cout << "Junho" << endl; break
     case 7 : cout << "Julho" << endl; break
     case 8 : cout << "Agosto" << endl; break
     case 9 : cout << "Setembro" << endl; break
     case 10 : cout << "Outubro" << endl; break
     case 11 : cout << "Novembro" << endl; break
     case 12 : cout << "Dezembro" << endl; break
     default : cout << "Digite um número de 0 à 12" << endl;
     }


}

.

    
asked by anonymous 22.02.2017 / 16:40

1 answer

2

The compiler showed what the error was, just read and fix it. ; is missing after every break to quit statement . Maybe if I had not put everything on the same line it would be clearer.

I gave a better organized code. More readable codes are easier to find errors.

#include <iostream>
using namespace std;

int main() {
    int x = 0;
    cout << "Qual o mês atual Digite apenas um número de 0 a 12" << endl;
    cin >> x ;
    switch (x) {
        case 1 : cout << "Janeiro" << endl; break;
        case 2 : cout << "Fevereiro" << endl; break;
        case 3 : cout << "Março" << endl; break;
        case 4 : cout << "Abril" << endl; break;
        case 5 : cout << "Maio" << endl; break;
        case 6 : cout << "Junho" << endl; break;
        case 7 : cout << "Julho" << endl; break;
        case 8 : cout << "Agosto" << endl; break;
        case 9 : cout << "Setembro" << endl; break;
        case 10 : cout << "Outubro" << endl; break;
        case 11 : cout << "Novembro" << endl; break;
        case 12 : cout << "Dezembro" << endl; break;
        default : cout << "Digite um número de 0 à 12" << endl;
     }
 }

See running on ideone . And No Coding Ground . Also I put it in GitHub for future reference .

    
22.02.2017 / 16:51