Q:

Find Biggest Number in C, by N number of inputs

So I have this code:
#include <stdio.h>
int main()
{
 char peopleName[5][20],peopleAge[5];
 int i;
 int maxAge=0, maxName=-1;
 for(i=0;i<5;i++)
 {
   printf("Name & Age %d :",i+1);
   scanf("%s",&peopleName[i]);
   scanf("%d",&peopleAge[i]);
 if(peopleAge[i]>maxAge)
 {
   maxAge=peopleAge[i];
   maxName=i;
 }
}
 printf("%s %d", peopleName[maxName],peopleAge[maxAge]);
}

This code finds from 5 people the oldest one. I want to change from 5 people to N number of people, whatever the number I input myself. (For example I put 7, and I can insert seven names and ages and so on).

A:

The question has two parts: How does the user specify how many persons are entered? And how do I store the data?
The second part is easy: No matter how many persons you are going to consider, if you just want to know who is the oldest, it is enough to keep the name and age of the currently oldest person. (Of course, if there is a tie and many people are, say, 80 years old, you just get to keep the first match.)
Not storing anything also simplifies the first question. You could ask the user to specify the number of persons beforehand and that's find if you have few people. If you have a list of many people, the user would have to count the by hand and then enter the count. Miscounting is very likely.
A better way is to indicate the end of input by another means, for example by a negative age or by two dashes as name. There is also the possibility that the input runs out, for example when redirecting input from a file or when pressing one of Ctrl-Z or Ctrl-D, depending on your platform, after the input.
The example below read the input line-wise and then scans that line. The loop while (1) is in theory infinite, in practice execution breaks out of the loop when the input runs out – fgets return NULL –, when a blank line is read or when the input isn't in the format single-word name and age.
#include <stdio.h>

int main(void)
{
    char oldest[80] = "no-one";
    int max_age = -1;
    int count = 0;

    puts("Enter name & age on each line, blank line to stop:");

    while (1) {
        char line[80];
        char name[80];
        int age;

        if (fgets(line, sizeof(line), stdin) == NULL) break;
        if (sscanf(line, "%s %d", name, &age) < 2) break;

        if (age > max_age) {
            strcpy(oldest, name);
            max_age = age;
        }

        count++;
    }

    printf("The oldest of these %d people is %s, aged %d.\n", 
        count, oldest, max_age);

    return 0;
}

