• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

C++ Syntax error

MxSoft

Leave Tibia, Live Life.
Joined
Dec 22, 2009
Messages
1,804
Solutions
1
Reaction score
43
Location
Mexico
Hello everyone, im getting syntax error, but i cant really find it:
C++:
#include <stdio.h>
#include <conio.h>
#include <string.h>

using namespace std;



int final=0;
int temp;
int rows;
int sumnumber;
int columns;
int answer;
int i;
int j;
int s;
char choice;
int row_mod;
int column_mod;
int data_mod;
int table[6][5]={ { 8147,6324,9575,9572,7218 },{ 9058,8975,7649,4854,4157 },{ 4270,5785,4576,8003,7922 },{ 9134,7469,7706,8419,9595 },{ 7579,9572,8010,6999,7922 },{ 3706,4854,4419,6157,7494 } };
char user[20];
char user_def[20];
int password;
int check;
int row;
int column;
int main()
{

    printf("Ingresa nombre de usuario:");
    gets_s(user);
    printf("Password:");
    password = getchar();

    check = strcmp(user, user_def);
    int gananciaT = 675.5;
    int gananciaImpuesto = 112.5;


    if(check = 0 && password == 151963)
    {
         bool menu = true;
        do
        {

            printf("Selecciona una de las siguientes opciones:  \n");
            printf("1: Despliegue de Datos\n 2: Correccion\n 3: Detalle por mes\n 4: Detalle por fabrica\n 5: Reporte General\n 6: Fabricas no sostenibles\n 7: Fabricas modelo\n 8: Ganancia Total\n 9: Salir\n \n");
            printf("Ingrese un numero: \n");
            choice = getchar();

            switch (choice){
                case 1:
                    printf("\n");
                    for(row=0;row<6;row++) {

                    for (column=0;column<5;column++) {
                        printf("%d\n", table[row][column]);
                    }
                    printf("\n");
                }
                break;

                for (i=0;i<6;i++) {
                    for (j=0;j<5;j++) {
                        printf("%d ", table[i][j]);
                    }
                    printf("\n");
                }
              
                case 2:
                printf("Seleccione Dato a corregir (Filas,Columnas) \n");

                printf("Fila: ");
                row_mod = getchar();
                printf("Columna: ");
                column_mod = getchar();
                printf("Nuevo Valor: ");
                data_mod = getchar();

                if(data_mod>0){
                    table[row_mod][column_mod] = data_mod;
                    printf("Datos Actualizados\n");
                }
                else printf("Dato invalido\n");

                break;
              
                case 3:
                printf("Produccion Mensual: \n");

                for(i= 0;i<5;i++){
                    for(j=0;j<6;j++){
                        s=s+table[j][i];
                        printf("Promedio mensual: %d+1 (  ( %d/6 (  piezas)))",i,s);
                        if((s / 6) > 7000){
                        printf(". Mes  ( %d + 1 (  supero 7000 piezas)",i);
                    }
                    s = 0;
                }
                break;
              
                case 4:
                printf("Produccion por Fabrica: \n");
                for(i=0;i<5;i++){
                    for(j=0;j<4;j++){
                        s=s+table[i][j];
                        printf("Produccion promedio de Fabrica  ( i + 1 (  es: ( s / 5)");
                    }
                        if((s/5)>8000){
                        printf(". Fabrica  ( i + 1 (  tuvo una produccion promedio mayor a 8000)");
                        }
                     s = 0;
                }

                break;
            case 5:
                printf("Reporte General: ");
                printf("Mejor Mes: ");
                printf("Peor Mes: ");
                printf("Mejor fabrica: ");
                printf("Peor fabrica: ");



                for (i = 0; i < 5; i++)
                {
                    for (j = 0; j < 6; j++)
                        s = s + table[j][i];
                    printf("%d", s);

                    temp = s;



                    if (temp > final) {
                        final = temp;
                        printf(" Mes  ( %d)", final);
                        printf(" Mes  ( %d)", i);

                    }

                    printf("end");
                    printf("%d ", s);
                    printf("%d", temp);
                    printf("%d", final);
                    s = 0;
                }


                printf("El Mes es %d", temp);
                break;

            case 6:
                printf("fabricas no sostenibles");
                for (i = 0; i < 5; i++)
                {
                    for (j = 0; j < 6; j++)
                        s = s + table[j][i];
                    printf("Promedio mensual  %d + 1  %d / 6", i, s);
                    if ((s / 6) > 6500) {
                        printf(" Mes  (%d + 1 ( supero 7000 piezas))",i);
                    }
                    s = 0;
                    break;

            case 7:
                printf("fabricas no sostenibles");
                for (i = 0; i < 5; i++)
                {
                    for (j = 0; j < 6; j++)
                        s = s + table[j][i];
                    printf("Promedio mensual  (%d + 1 ( (%d / 6 ( piezas))",i,s);
                    if ((s / 6) > 7000)
                    {
                        printf(". Mes  (%d + 1 ( supero 7000 piezas))",i);
                    }
                    s = 0;
                    break;


            case 8:
                printf("gananciaT,gananciaImpuesto");
                break;
            case 9:
                printf("Apagando...");
                break;

            default:
                printf("Seleccione una opcion (1 - 9)\n");

                }

                }
                while (choice != 9){
                getchar();
                getchar();
                }
              

            }
            if (password >= 3){
                printf("acceso denegado");

            }
            else {
                printf("Usuario o Contraseñ¡ ©ncorrectos\n");


            }
        }
    }
    }
}

151963-2.cpp(214): error C2059: error de sintaxis: '}'



Is for a university homework, is some could explain what im doing bad please.
 
You have nested cases, you are missing a closing bracket for the for loop in case 7 which is causing the code to nest case 8, 9 & default inside of case 7. That is just for starters, when you fix that then 7 is enclosed inside of case 6... Your code is all messed up, it seems as if you copied and pasted it from someone or somewhere.

Every case in a switch statement except for default should have a break statement to prevent it from executing the following case. But your code does something entirely different you have break statements either sitting inside of loops or in between loop executions. A break statement is similar to a return statement, once its reached that is the end of the call.
 
Last edited:
Back
Top