Forum > General

pascal a bit trouble with program :(

(1/7) > >>

burak:
Hello, i have written program like this ...

Program j;
var f, g,a, b, c, m, i:integer;

begin
for i:=2 to g do
for a:=1 to 9 do
for b:=1 to 9 do
for c:=1 to 9 do
begin
m:a*100+b*10+c;
if (m mod a=0) and
(m mod b=0) and
(m mod c=0) then
write1n(' ', m);
end;
end.

But its not working right ... u can run it but it will find weird numbers :))

Can anyone help me out ??
May some one check the program and correct it please ? :)

burak:
A positive integer N is called a " fair " if it is divisible by each of its digits. For example, the number 132 is fair , because it is divisible by 1 , 3 and 2. In contrast the number 123 is not fair, since , although divisible by 1 and 3 but not divisible by 2. Write a function that determines whether a fair number N ( N the parameter is a function). Next, write a program which uses this function finds and displays all the honest numbers range from A to B, including ( value of A, B will be awarded to the entry of the program - are positive integers from the range of data type integer.

Bart:
First describe the steps needed to accomplish this task.

Here are the first few steps (dont worry about the code yet):
- get all the digits out of a number (e.g. 1231 -> 1 and 2 and 3)
- try if the number can be divided by all of the digits (what to do if a number contains a zero?)

This basically describes the algorithm for determining if a number is "fair"

Do the same (describing the steps) for the procedure that determines that for a range of numbers from A to B.

After that translate each step into Pascal code, you may want to look into sets (and the operator in), div, mod.

Try to compile the code, show us the code and any errors in it.
At that stage we will help.

We won't do your assigment for you.

Bart

burak:
Well, i have only like a day left so i have to ask if there is any chance to pay for the program ?? If yes how much it may cost and how can i pay :p

Bart:

--- Quote from: burak on November 07, 2014, 04:51:30 pm ---Well, i have only like a day left
--- End quote ---

Well, start then.

Break down the problem in steps.
Post it here, get feedback.

Write code.
Post it her, get feedback.

Should not take you more than a few hours.

--- Quote from: burak on November 07, 2014, 04:51:30 pm ---so i have to ask if there is any chance to pay for the program ?? If yes how much it may cost and how can i pay :p

--- End quote ---

I guess this is either a joke, or you are not willing to learn anything from you assignement at all.
If the latter is the case, I will do it for you if you promise me two things:

* Never do any programming in your life ever!
* Never work in healthcare, given your current attitude towards learning. You will kill people.
I require €500 to be paid to the Lazarus PayPal account (and proof that it has been  paid, since I don't have access to that account.

Bart