Because when I use cin inside a for there is no pause?

1

Hi, I've put a cin in a for so that I go asking for information but when I do it, it does everything for me, for example:

When should I ask for one for one. Part of the code:

int entradas,t;
    cout << "Introduce el numero de entradas:";
    cin >>entradas;
    int ar[entradas];
    for(t=0;t<entradas;t++)
        cout << "Introduce un numero: ";
        cin >> numero;

Does anyone know why he does those jumps I can not enter several numbers?

    
asked by Sergio Ramos 11.03.2017 в 13:21
source

1 answer

4
for(t=0;t<entradas;t++)
  cout << "Introduce un numero: ";
  cin >> numero;

Since the for takes more than one instruction you have to enclose the code between braces

for(t=0;t<entradas;t++)
{
  cout << "Introduce un numero: ";
  cin >> numero;
}
    
answered by 11.03.2017 / 13:34
source