I am trying to figure out when I enter the data instead of asking for person #1: everytime I can get it to ask person #1: then on the next line person #2: and so on. Here is my code so far:

#include "stdafx.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
    const int People = 5;
    int i, PeopleTypes[People];
cout << "Enter 1 for Infant, 2 for Child, 3 for Teenager, or 4 for Adult\n";
cout << "for each person that attended the school function.\n\n";
    for(i=0; i<People; i++)
        cout << "Person #1: ";
        cin  >> PeopleTypes[i];
    return 0;
10 Years
Discussion Span
Last Post by WaltP

You already have a counter, so just print that value instead of something hard coded:

cout << "Person #" << i + 1 << ": ";

Does anyone think this program is better set up like I got it or should I use switch or if-else. I have to be able to stop when a negative value is entered and have invalid input displayed if any other integer besides 1,2,3, and 4 are entered.


How many threads are we working with for this program? Maybe you should have only one thread so no one gets confused. Especially you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.