Help! Age Generator Program advice

Hi there,

i have just started a computing course at college, and need some help with a program that we have been set as a starter. The program itself should ask the user for their date of birth, then when the user inputs the data ( for example 29/10/1976) the program should reply with 'Your date of birth is '29th October 1976'' Please could anybody write a program for me which could do this, then post it in this thread? thanks


  • [code]
    program Age_Generator;
    var data: string[10]; // 'dd/mm/yyyy'
    procedure reply (data: string[10]);
    var day, month, tmp: integer;
    val(copy(data, 1, 2), day, tmp); // copying from 1st position
    { if there was a converting mistake tmp would show position in string
    where it starts }
    val(copy(data, 4, 2), month, tmp);
    write ('Your date of birth is ' + #39);
    case day of
    1: write ('1st ');
    2: write ('2nd ');
    3: write ('3rd ');
    else write (day, 'th ')
    case month of
    1: write ('January ');
    2: write ('February ');
    3: write ('March ');
    4: write ('April ');
    5: write ('May ');
    6: write ('June ');
    7: write ('July ');
    8: write ('August ');
    9: write ('September ');
    10: write ('October ');
    11: write ('November ');
    12: write ('December ')
    writeln (copy(data, 7, 4) + #39) // year
    writeln ('Enter your day of birth');
    readln (data);
    reply (data);
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion