dimanche 24 juillet 2016

Pause loop operation until user provides complete input

In the code below, I am attempting to gather data from the user. However, the program accepts one input, then proceeds to print the remaining prompts to the screen.

How do I get the program to pause so that it collects data at each prompt from the user?

#include <iostream>

using namespace std;

int main (){

char items [10];
float budget;
float prices [10];
int i;

for ( i = 0; i < 10; i++ ){
    cout << "Enter item name: "<<endl;
    cin >> items[i];
    cout << "Enter item price: "<<endl;
    cin >> prices [i];

    }

}

Aucun commentaire:

Enregistrer un commentaire