Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Become a Premium Member and unlock a new, free course in leading technologies each month.

Solved

Posted on 2000-04-17

Here's my program:

var i: integer;

type string10 = string[10];

const

ones: array[0..9] of string10 = ('', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');

tens: array[0..9] of string10 = ('','ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety');

function wordnumber (number: word) : string;

begin

wordnumber:= tens [number div 10] + '-' +ones [number div 10];

end;

begin {main}

for i:= 20 to 99 do

writeln ('You write ',i, ' like this: ', wordnumber(i));

end.

This is the output it's giving me:

'You write 20 like this: twenty-two'

It gives me twenty-two from 20 to 29.

I'm having similar problems with the other numbers:

'You write 30 like this: thirty-three' I get thirty-three from 30 to 39.

'You write 40 like this: forty-four' I get forty-four from 40 to 49.

'You write 50 like this: fifty-five' I get fifty-five from 50 to 59.

'You write 60 like this: sixty-six' I get sixty-six from 60 to 69.

'You write 70 like this: seventy-seven' I get seventy-seven from 70 to 79.

'You write 80 like this: eighty-eight' I get eighty-eight from 80 to 89.

'You write 90 like this: ninety-nine' I get ninety-nine from 90 to 99.

BTW... The program is supposed to let the user enter a number from 20 rto 99 and it outputs the number in equivalent number form.

var i: integer;

type string10 = string[10];

const

ones: array[0..9] of string10 = ('', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');

tens: array[0..9] of string10 = ('','ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety');

function wordnumber (number: word) : string;

begin

wordnumber:= tens [number div 10] + '-' +ones [number div 10];

end;

begin {main}

for i:= 20 to 99 do

writeln ('You write ',i, ' like this: ', wordnumber(i));

end.

This is the output it's giving me:

'You write 20 like this: twenty-two'

It gives me twenty-two from 20 to 29.

I'm having similar problems with the other numbers:

'You write 30 like this: thirty-three' I get thirty-three from 30 to 39.

'You write 40 like this: forty-four' I get forty-four from 40 to 49.

'You write 50 like this: fifty-five' I get fifty-five from 50 to 59.

'You write 60 like this: sixty-six' I get sixty-six from 60 to 69.

'You write 70 like this: seventy-seven' I get seventy-seven from 70 to 79.

'You write 80 like this: eighty-eight' I get eighty-eight from 80 to 89.

'You write 90 like this: ninety-nine' I get ninety-nine from 90 to 99.

BTW... The program is supposed to let the user enter a number from 20 rto 99 and it outputs the number in equivalent number form.

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

- Help others & share knowledge
- Earn cash & points
- Learn & ask questions

1 Comment

There's one misstake in your code,

One of the "div"s should be a "mod"

Here's a modifyed version of your code

var i: integer;

type string10 = string[10];

const

ones: array[0..9] of string10 = ('', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');

tens: array[0..9] of string10 = ('','ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety');

function wordnumber (number: word) : string;

begin

wordnumber:= tens [number div 10] + '-' +ones [number mod 10];

end;

begin {main}

for i:= 20 to 99 do

writeln ('You write ',i, ' like this: ', wordnumber(i));

end.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's recap what we learned from yesterday's Skyport Systems webinar.

- Ransomware
- Experts Exchange
- Skyport Systems
- Active Directory
- Security
- *privileged credentials

Earn Certification

HTML5 Specialist - Certification

Free withPremium

Course of the Month5 days, 7 hours left to enroll

Join the community of 500,000 technology professionals and ask your questions.