tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
26
Task/Binary-digits/COBOL/binary-digits.cobol
Normal file
26
Task/Binary-digits/COBOL/binary-digits.cobol
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. SAMPLE.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
|
||||
01 binary_number pic X(21).
|
||||
01 str pic X(21).
|
||||
01 binary_digit pic X.
|
||||
01 digit pic 9.
|
||||
01 n pic 9(7).
|
||||
01 nstr pic X(7).
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
accept nstr
|
||||
move nstr to n
|
||||
perform until n equal 0
|
||||
divide n by 2 giving n remainder digit
|
||||
move digit to binary_digit
|
||||
string binary_digit DELIMITED BY SIZE
|
||||
binary_number DELIMITED BY SPACE
|
||||
into str
|
||||
move str to binary_number
|
||||
end-perform.
|
||||
display binary_number
|
||||
stop run.
|
||||
Loading…
Add table
Add a link
Reference in a new issue