Tom Dawes-Gamble
Site Navigation:
 
 
int x  1;
     /*  Author.  Tom Dawes-Gamble
      *  This program compiles in both the GNU C
      *        and Micro Focus COBOL compilers.
      *
      *  The program prints a message to indicate the Language used
      *  and the size of the error in the calculation.
      *
      *  Of course idealy the error should be zero.
      *  COBOL seems to be able to be better than C in this case.
      *
      *  Below are comands to compile and run the program.
      *  cc -Wall -o better better.c
      *  cob better.cbl
      *
      *  ./better 
      *  When the program is written in C the error is 0.00000095367431641
      *
      *  cobrun better.int
      *  When the program is written in COBOL the error is 0.00000000000000000
      *
      */
#include <stdio.h>
      double         answer;
#  ifndef pic
#         define          pic  9.9(17).
#endif procedure division.
int    main                                                                ()
{
#  ifndef  c
#     define c char
c *d=" .*>";
c        compute;
      d = &compute;
#endif
#     define define answer
#     define display printf("%.32s%s%1.17f\n",
#     define stop exit()
#     define run

        define =  1111111111.1111 * 5.5555 - 6172777777.77771605;
        display "When the program is written in COBOL",
                " the error is " , define                                   );
        stop run;
}

 
 
 
 

© Copyright 1997, 2004 Tom Dawes-Gamble

CSS Valid XHTML 1.1! Valid CSS! * Best viewed with any browser: