This looks like a homework so you have to post the code of what you've done so far and we can help you then if there are some mistakes.

Solved

Posted on 2006-04-24

Hey,

Wondered if anyone might have any idea how to do this program, been giving me a bit of hassle. Thanks a million!

y=loge(x), i need to write a program which will display a table of logs for varying values of x. Theuser should be instructed to enter the minimum value of x, the maximum value and the size of increment between these values. The program should then use one procedure to calculate thevalues of x and store them in an array and another procedure to calculate the corresponding values of y (also in an array).

e.g.. the user has entered xmin = 0.1, xmax = 1.0, xincrement = 0.05

The x array will therefore have the values :

0.10, 0.15, 0.20, …. Which will fill the x array.

And the y array will therefore have the values :

-2,30, -1.89, -1.61, …. Which will fill the y array.

You will have to make sure the user can't ask for more points than are contained in the array.

For example, if you define your arrays to have 50 elements and the user needs 100 points

between xmin and xmax then you must stop and warn the user that they have asked for too many

points and ask them to try again..

Wondered if anyone might have any idea how to do this program, been giving me a bit of hassle. Thanks a million!

y=loge(x), i need to write a program which will display a table of logs for varying values of x. Theuser should be instructed to enter the minimum value of x, the maximum value and the size of increment between these values. The program should then use one procedure to calculate thevalues of x and store them in an array and another procedure to calculate the corresponding values of y (also in an array).

e.g.. the user has entered xmin = 0.1, xmax = 1.0, xincrement = 0.05

The x array will therefore have the values :

0.10, 0.15, 0.20, …. Which will fill the x array.

And the y array will therefore have the values :

-2,30, -1.89, -1.61, …. Which will fill the y array.

You will have to make sure the user can't ask for more points than are contained in the array.

For example, if you define your arrays to have 50 elements and the user needs 100 points

between xmin and xmax then you must stop and warn the user that they have asked for too many

points and ask them to try again..

5 Comments

This looks like a homework so you have to post the code of what you've done so far and we can help you then if there are some mistakes.

PROGRAM ln_example;

VAR

list : ARRAY [0..100] OF integer;

loge : ARRAY[ARRAY[0..10] OF integer OF O..100;

num : integer;

inc : integer;

numz : integer;

BEGIN

begin

num := num + inc;

IF num > 0 AND num <= numz DO

list (ARRAY[num]);

end;

begin

loge := ln(lit(num));

end;

writeln('Please enter minimum x value: ':2);

readln(num);

writeln('Please enter maximum x value: ':2);

readln(numz);

writeln('Please enter size of increment: ':2);

readln(inc);

writeln(loge[num]);

END.

if you could point out what ive done wrong, that would be amazing. thanks.

what is the idea of this one?

what is ARRAY[ARRAY

also in O..100 I suppose it has to be 0 (zero) not O (the letter O)

Since your list is 1 - 100 then your array for the loge must also be 1 - 100. Same basic declaration.

Have you learned about user defined data types? Have you learned about functions and procedures?

THink about how you would do this manually

Step 1 - Ask user how many values, minimum value, and increment

Step 2 - Validate values - what values for each would be invalid - (More than your program allows, negative minimum value, etc)

Repat step 1 & 2 for each invalid value

Step 3 -

mlmcc

list : ARRAY [0..100] OF integer;

loge : ARRAY[ARRAY[0..10] OF integer OF O..100;

num : integer;

inc : integer;

numz : integer;

As an example you used real type values. It is not possible to store such values in variables you declared. The variables have to be real type to work correctly in such a case:

const SizeOfArray = 100;

VAR

list : ARRAY [0..SizeOfArray] OF Real;

loge : ARRAY [0..SizeOfArray] OF Real;

num : Real;

inc : Real;

numz : Real;

The SizeOfArray constant is just to make changing of the array size more easy. But it shows the both arrays have to be the same size. It is possible to declare 1 variable instead of two. But, you told us you have to create two separate tables. So, I'll leave it, for now.

The rest of your program should follow the steps, just like Mlmcc said. The validation of the values should be done in some sort of a loop. Repeat .. Until is a possible solution:

BEGIN

repeat

{STEP 1 - Ask user how many values, minimum value, and increment}

writeln('Please enter minimum x value: ':2);

readln(num);

writeln('Please enter maximum x value: ':2);

readln(numz);

writeln('Please enter size of increment: ':2);

readln(inc);

writeln(loge[num]);

{Step 2 - Validate values}

until (validation expression goes here)

{Step 3 - }

END.

Title | # Comments | Views | Activity |
---|---|---|---|

How to unescape(decode) an encoded string? | 5 | 1,318 | |

Real time Change DisplayName of service | 7 | 580 | |

How to open a file in read-write mode, and lock out others | 2 | 262 | |

Activex get website that activex running on | 3 | 66 |

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

Connect with top rated Experts

**15** Experts available now in Live!