I get an error in case and I do not know why please help urgently [closed]

-3
 #include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int main(void)
{int i,n1,n2,sum,res,mul,div,n;
printf("INGRESE LA OPCION QUE DESEA ");
scanf("%d",&i);
switch(i)
case 1:
printf("/n Ingrese un numero");
scanf("%d",&n);
if(n>0)
    {printf("/n POSITIVO");}
    else
    {if(n<0)
    printf("/n NEGATIVO");}
    system("PAUSE");
    return 0;}
{ case 2:
    printf("in opcion suma");
    printf("in ingrese el primer numero");
    scanf("%d",&n1);
    printf("in ingrese el segundo numero");
    scanf("%d",&n2);
    sum=n1+n2;
    printf("la suma es: %d",sum);
    break;
    case 2:
        printf("in opcion de resta");
        printf("in ingrese el primer numero");
        scanf("%d",&n1);
        printf("in ingrese el segundo numero");
        scanf("%d",&n2);
        res=n1-n2;
        printf("la resta es:%d",res);
        break;
        case 3:
            printf("in opcion de multiplicacion");
                    printf("in ingrese el primer numero");
                    scanf("%d",&n1);
                    printf("in ingrese el segundo numero");
                    scanf("%d",&n2);
                    mul=n1*n2;
                    printf("la multiplicacion es:%d",mul);
                    break;
                    case 4:
                        printf("in opcion division");
                                printf("in ingrese el primer numero");
                                scanf("%d",&n1);
                                printf("in ingrese el segundo numero");
                                scanf("%d",&n2);
                                div=n1/n2;
                                printf("la division es: %d",div);
                                break;
}}
{ case 3:
    {printf("OPCION DE EDAD")
     int edad;
     printf( "\n   Introduzca edad: " );
     scanf( "%d", &edad );

    if ( edad >= 0 && edad <= 120 )
        if ( edad < 2 )
            printf( "\n   BEB%c", 144 );
        else
            if ( edad < 13 )
                printf( "\n   NI%cO", 165 );
            else
                if ( edad < 18 )
                    printf( "\n   ADOLESCENTE" );
                else
                    if ( edad < 31 )
                        printf( "\n   JOVEN");
                    else
                        if ( edad < 65 )
                            printf( "\n   ADULTO" );
                        else
                            printf( "\n   ANCIANO" );
    else
        printf( "\n   ERROR: Edad incorrecta." );

    getch(); /* Pausa */

   return 0;
}}
    
asked by Santiago 01.02.2018 в 21:29
source

2 answers

1

The error is in your switch, it's like this:

switch(Variable){
case 1: código;
break
case 2: código;
break;
default: código;
break;
}

You are missing the key after the switch parentheses.

    
answered by 01.02.2018 в 22:03
0

on line 19 you have a "{" badly placed, you must correct the syntax.

link

switch(1) {
    case 1: {  int x = 0;
               std::cout << x << '\n';
               break;
            } // scope of 'x' ends here
    default: std::cout << "default\n"; // no error
             break; 
}
    
answered by 01.02.2018 в 22:08