Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user

The ages.c code doesn't seem to account for a scenario where user enters a negative integer when prompted for ages.

{ for (int i = 0; i < n; i++) { printf("Age of person #%i: ", i + 1); ages[i] = GetInt();
} }

   {
       for (int i = 0; i < n; i++)
       {
           printf("Age of person #%i: ", i + 1);
           ages[i] = GetInt();   
       }
   }

What type of loop could one add to reprompt user for a positive integer?

The ages.c code doesn't seem to account for a scenario where user enters a negative integer when prompted for ages.

{ for (int i = 0; i < n; i++) { printf("Age of person #%i: ", i + 1); ages[i] = GetInt();
} }

What type of loop could one add to reprompt user for a positive integer?

The ages.c code doesn't seem to account for a scenario where user enters a negative integer when prompted for ages.

   {
       for (int i = 0; i < n; i++)
       {
           printf("Age of person #%i: ", i + 1);
           ages[i] = GetInt();   
       }
   }

What type of loop could one add to reprompt user for a positive integer?

Source Link

Week 2 walkthroughs ages.c has a bug?

The ages.c code doesn't seem to account for a scenario where user enters a negative integer when prompted for ages.

{ for (int i = 0; i < n; i++) { printf("Age of person #%i: ", i + 1); ages[i] = GetInt();
} }

What type of loop could one add to reprompt user for a positive integer?