Why can’t programmers program?.
The logic for this is really very simple. I was able to do in both Swift and JavaScript, which I am learning, in hardly any time.
Because of the variations in language structure, I couldn’t exactly use the "for(int i=0;"
exactly,
Here is my code in JavaScript:
for (i = 0; i < 100; i++) {
console.log(100-i);
}
Here is my code in Swift:
for var i = 0; i < 100; ++i {
println(100 - i)
}
In Cobol, my “native” programming language, it would take a few more lines of code:
identification division.
program-id. print100to1.
data division.
working-storage section.
01 work-areas.
05 work-count picture 999.
05 display-count picture zz9.
procedure division.
perform varying work-count from 0 by 1
until work-count greater than 99
subtract 100 from work-count giving display-count
display display-count upon sysout
end-perform.
stop run.
While Cobol is more “wordy” and you need to split out your data from your logic it is fairly self-documenting once you understand the basics of Cobol.
When I write a new Cobol program I often start by copying an existing program that has much of the logic I need already in it.
Leave a Reply