Sunday, September 6, 2009

16. Computer Programming with flowcharting Technique (page 16)

free counters



Problem 11 You are asked to makes program to print article NEW YORK 10 times then town METROPOLITAN counted 3 times.
The process is repeated 5 times

Solution
To print 10 times is given by iteration constrain 10 times with Counter A
To print 3 times is given by iteration constrain 3 times with Counter B
To repeat the process 5 times is determined with Counter C

Logic:
Does iteration 10 times to print word " NEW YORK"
Does iteration counted 3 times to print word " town METROPOLITAN"
Does iteration counted 5 times to redo the process.

Programming stages and steps: Determines string variable to say NEW YORK and town METROPOLITAN
Process looping with iteration 10 times for counter and word NEW YORK

Description Every completed printing 10 times word " NEW YORK" , counter A in zero isn't it ( A = 0)
( line number 100 )
So also completed printing 3 times word " town METROPOLITAN" counter B also in zero isn't it ( line number 140 ). This process alike in filling gasoline station. Having filling gasoline in each vehicle, counter in zero isn't it to start calculates gasoline litre at the next vehicle.

At problem 11 is counter zero A = 0 and B = movable 0 at line after number 50 for example 51 A = 0 and 52 B = 0 . Result of its is being equal.

FIG.18

Output
First iteration
NEW YORK NEW YORK NEW YORK NEW YORK NEW YORK NEW YORK NEW YORK NEW YORK NEW YORK NEW YORK town METROPOLITAN town METROPOLITAN town METROPOLITAN
Second iteration
NEW YORK NEW YORK NEW YORK NEW YORK NEW YORK NEW YORK NEW YORK NEW YORK NEW YORK NEW YORK town METROPOLITAN town METROPOLITAN town METROPOLITAN
etc until 10th iteration.

15. Computer Programming with flowcharting Technique (page 15)

free counters


6.2. Looping and single looping
Problem 10
You are asked to makes program to print article NEW YORK 10 times , then prints on start number - 4 until number 100 with difference 7

Solution
To print word NEW YORK must be given iteration constrain 10 times
First number - 4 with difference = 7
Until number 100

Logic:
Does iteration 10 times to print word NEW YORK (Counter X)
Then does iteration to print number asked by determining initial number, different and last number 100. (Counter N)

Programming stages and steps:
Determines string variable to say NEW YORK
Determines initial number (non first number) that is - 4 -( 7) = - 11
Process looping with iteration 10 times for counter X and word NEW YORK
After completed does iteration to print number asked (Counter N)


FIG.17
Output :
NEW YORK NEW YORK NEW YORK - - - to 10 times then
Number - 4 3 10 17 and hereinafter

14. Computer Programming with flowcharting Technique (page 14)

free counters


Problem 9
You are asked to makes program to print article NEW YORK 10 times and every article is given massage number 1 up to 10

Solution
To print 10 times must be given iteration constrain 10 times

Logic:
Does iteration 10 times to print sequential number and word NEW YORK

Programming stages and steps:
Determines string variable to say NEW YORK
Process looping with iteration 10 times for counter and word NEW YORK

Description
Counter is calculation at iteration process

PROG009


FIG.16

Output: 1NEW YORK2NEW YORK3NEW YORK and so on

Additional description:
If line number 60 changed by PRINT X ; " " ; A$
Output:
1 NEW YORK
2 NEW YORK
3 NEW YORK and so on

13. Computer Programming with flowcharting Technique (page 13)

free counters


6. Continuation of iteration: Looping
6.1. a. Single Loop
Problem 8
You are asked to makes program to print article NEW YORK 10 times

Solution
To print 10 times must be given iteration constrain 10 times

Logic:
Does iteration 10 times to print word NEW YORK

Programming stages and steps:
Determines string variable to print NEW YORK
Process looping with iteration 10 times

PROG008

FIG.15

At line number 60 PRINT A$ ; " " ; to print space between article New York

Output
After in execution (RUN) result:

New York New York New York New York New York New York New York New York New York New York

12. Computer Programming with flowcharting Technique (page 12)

free counters


Problem 7
You are requested to make a program sort the number of the largest to the smaller number is determined when the number of three-INPUT is not the same magnitude.

Solutions
Eg the number of K, L and M
Logic:
The first is the largest, followed by a smaller number and the last is the smallest.
Programming steps:
compare K with L, and the winner compare with M, the winner is the first order
Losers compare with others who also lost for a second.
The remaining sequence is the last (the smallest)

FIG.14


Sequence logic is logic that is very difficult when data amounts which will be sorted quite a lot.

DATA TEST: Sees example before all

Output

For two data A and B is obtained by 2 output that is A,B and B,A = 2 ! = 1 x 2 = 2

For three data K,L,M is obtained by 3 ! ( factorial) = 1 x 2 x 3 = 6 output that is:

( K,L,M ), ( K,M,L ), ( L,K,M ), ( L,M,K ), ( M,K,L ) and ( M,L,K )

For four data P,Q,R,S will be got output 4 ! = 1x2x3x4 = 24 output

That way further.

Sequence four data is not done here because its flowchart is too big.

At computing process, there is tens of data sequence program which has been found. Till now the expert still looking for quickest program to sort data in gross.

11. Computer Programming with flowcharting Technique (page 11)

free counters


5.4.2. SORTING ( Sequence) just for limited data ( maximum of 4 data)

Problem 6
You are asked to makes program to sort numeral from the biggest number to smaller number determined by INPUT two level unegual numbers.
Solution
For example the number A and B

Logic:
First number is the biggest number, followed smaller number.

Programming stages,steps:

Confronts A with B, the winner is first number.

If A > B hence sequence is A, B
If no, means A smaller than B  (A < B), hence sequence is B, A


FIG.13

TEST DATA : Sees example before all

10. Computer Programming with flowcharting Technique (page 10)

free counters


The problem of 5
You are asked to makes program to present the biggest number from INPUT four level unequal numbers.

Solution
For example the number P, Q, R and S

Logic:
The biggest number is number the always bigger if compared to three other number.

Programming stages and steps:
Confronts P with Q, the winner matched with R and the winner is confronted with S
At Flowchart under this Y (Yes) towards right and N (NO) downwards
Input P, Input Q, Input R and Input S can be summarized to become INPUT P,Q,R,S
When executed (in RUN) will come up ? ( enters input)
Writes numeral 4 by dissociated by sign , ( comma) for example 452 , 317 , 9054 , 22
Then press ENTER


DATA TEST : test your program with this input data
P , Q , R , S
data 1 : 1 , 2 , 3 , 4
data 2 : 1 , 2 , 4 , 3
data 3 : 1 , 3 , 2 , 4
data 4 : 1 , 3 , 4 , 2
data 5 : 1 , 4 , 2 , 3
data 6 : 1 , 4 , 3 , 2
data 7 : 2 , 1 , 3 , 4
data 8 : 2 , 1 , 4 , 3
data 9 : 2 , 3 , 1 , 4
data 10 : 2 , 3 , 4 , 1
data 11 : 2 , 4 , 1 , 3
data 12 : 2 , 4 , 3 , 1
data 13 : 3 , 1 , 2 , 4
data 14 : 3 , 1 , 4 , 2
data 15 : 3 , 2 , 1 , 4
data 16 : 3 , 2 , 4 , 1
data 17 : 3 , 4 , 1 , 2
data 18 : 3 , 4 , 2 , 1
data 19 : 4 , 1 , 2 , 3
data 20 : 4 , 1 , 3 , 2
data 21 : 4 , 2 , 1 , 3
data 22 : 4 , 2 , 3 , 1
data 23 : 4 , 3 , 1 , 2
data 24 : 4 , 3 , 2 , 1
OUTPUT is number 4 ( the biggest number out of the four data)

Hereinafter you input can having kinds of number

Followers

Blog Archive