Dev - C++ - Error expected identifier before ‘;’ token y expected initializer before ‘int’

 
Vista:

Error expected identifier before ‘;’ token y expected initializer before ‘int’

Publicado por JOJO (1 intervención) el 29/03/2023 00:07:27
/******************************************************************************

condicional simple (if) y condicionante doble (if, else)

if (condicion){
instrucciones 1;
}
else {
instrucciones 2;
}

comparacion entre 2 numeros

*******************************************************************************/
#include <iostream>

using namespace; int main()

int main()
{
int num dato=7;
cout<<"inserta un numero";
cin>>num;

if (dato==num){
cout<<"Tu numero es el 7";
}
else{
cout<<"Tu numero no es el 7";
}
return 0;
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 1.440
Bronce
Ha mantenido su posición en Dev - C++ (en relación al último mes)
Gráfica de Dev - C++

Error expected identifier before ‘;’ token y expected initializer before ‘int’

Publicado por dario (718 intervenciones) el 29/03/2023 02:55:16
Arreglado y corregido:
NOTA: Cuando tengas una sola instruccion dentro del IF o ELSE no son necesarias las llaves de inicio y fin.
Salu2.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
 
using namespace std;
 
int main()
{
    int num,dato=7;
 
    cout << "inserta un numero: ";
    cin >> num;
 
    if (dato == num)
        cout << "Tu numero es el 7" << endl;
    else
        cout << "Tu numero no es el 7" << endl;
 
    return 0;
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar