I have designed an age calculator which given a person's age, works out given a person's age, works out how many days they have lived for, and how many hours they have lived for.

My answer:

var
age, month, day, hour: integer;

begin
writeln ('How old are you?');
readln (age);
writeln ('Please enter the number of months since your last birthday.');
readln (months);
days:=age*365+months*30;
hours:=days*24;
writeln ('Your age in days is ', days,' ,');
writeln ('Your age in hours is ', hours,' ,');
sleep (50000);
end.

My question is: what is the meaning of the comma and delimiter in the red colour? It is because I usually forget to put comma and/or delimiter in this circumstance.

Cheers,

Recommended Answers

All 2 Replies

The comma separates the arguments you provide to a function. Seems to me you have too many commas here. You have two arguments a string and an integer, separate them with one comma.
B.t.w. your calculation is wrong. What about leap years?

writeln ('Your age in days is ', days,' ,');

when you write the argument to the 'writeln' you need to write it carefully.If you want to show proposition,or simple words you need to use delimiter

WriteLn('Hello World!');{shows these chars to the screen}
{but if you want to show a value of a variable then
you have to use comas}
age:=13;
day:=22;
WriteLn('Your age is: ',age,' and ',day,'days.');
{On the screen..} 
Your age is 13 and 22 days.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.