Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Cobol/verschiedene-Autoren/Fraunhofer/   (verschiedene Autoren Version 0.7©)  Datei vom 2.9.2010 mit Größe 123 kB image not shown  

Quelle  primitive-p629.cob   Sprache: Cobol

 

       identification division.
       program-id. succ.
      * aus Herold/Lutz/Wohlrab
      * Grundlagen der Informatik
      * p. 629
       author. JD.
       date-written. 3.11.2008.
       date-compiled.
       data division.
       linkage section.
       77 x pic 9(8).
       77 r pic 9(8).
       procedure division using x  returning r.
          add 1 to x giving r.
        end-program succ.

       identification division.
       program-id. pred.
       data division.
       linkage section.
       77 x pic 9(8).
       77 r pic 9(8).
       procedure division using x  returning r.
          if x=0 move 0 to r else subtract 1 from x giving r.
        end-program pred.

       identification division.
       program-id. adder.
      * dito
       data division.
       linkage section.
       77 x pic 9(8).
       77 y pic 9(8).
       77 r pic 9(8).
       procedure division using x y returning r.
          if x=0 move y to r
          else
           compute r=function succ (function adder(function pred(x),y)).
        end-program adder.

       identification division.
       program-id. mult.
      * dito
       data division.
       linkage section.
       77 x pic 9(8).
       77 y pic 9(8).
       77 r pic 9(8).
       procedure division using x y returning r.
          if x=0 move 0 to r
          else
            compute r=function adder(function mult(function pred(x),y))
        end-program mult.

       identification division.
       program-id. main.
      * dito
       data division.
       working-storage section.
       77 x pic 9(8).
       77 y pic 9(8).
       77 r pic 9(8).
       procedure division using x y returning r.
          display "Gib zwei Zahlen durch Kommata getrennt ein:"
          accept x
          accept y
          move function adder(x,y) to r
          display "Add("x","y")="r
          move function mult(x,y) to r
          display "mult("x","y")="r
        end-program main.

Messung
CHZG
8610010095

¤ Dauer der Verarbeitung: 0.4 Sekunden  (vorverarbeitet am  2026-11-24) ¤

*© Formatika GbR, Deutschland