home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / fortran / 3147 < prev    next >
Encoding:
Text File  |  1992-08-25  |  2.6 KB  |  74 lines

  1. Path: sparky!uunet!paladin.american.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!The-Star.honeywell.com!umn.edu!noc.msc.net!uc.msc.edu!shamash!ems!ems.cdc.com!mstemper
  2. From: mstemper@ems.cdc.com (Michael Stemper)
  3. Newsgroups: comp.lang.fortran
  4. Subject: Re: Help. Need Help in writing this program.
  5. Message-ID: <21195@nntp_server.ems.cdc.com>
  6. Date: 25 Aug 92 17:59:22 GMT
  7. References: <1992Aug24.183954.24423@uceng.UC.EDU>
  8. Sender: sys@ems.ems.cdc.com
  9. Reply-To: mstemper@ems.cdc.com
  10. Organization: Empros Systems International, a division of Ceridian
  11. Lines: 60
  12. Nntp-Posting-Host: kirk.ems.cdc.com
  13.  
  14. In article <1992Aug24.183954.24423@uceng.UC.EDU>, pviswana@uceng.UC.EDU (Prashanth V.) writes:
  15. |> 
  16. |> The input is the number of Branch instructions the fortran program
  17. |> must contain.
  18. |> 
  19. |> Ouput a fortran program that will contain the specified number of 
  20. |> branch instructions. Is this possible in Fortran?
  21. |> 
  22. Well, it depends on what you mean by branch instructions. If you mean
  23. that your program is to generate another program that has a specified
  24. number of GO TO statements, would the following be an acceptable output
  25. of your program, given an input of 4?
  26.  
  27.       PROGRAM ANSWER
  28. *
  29.       GO TO     1
  30.     1 CONTINUE
  31. *
  32.       GO TO     2
  33.     2 CONTINUE
  34. *
  35.       GO TO     3
  36.     3 CONTINUE
  37. *
  38.       GO TO     4
  39.     4 CONTINUE
  40. *
  41.       STOP
  42.       END
  43.  
  44. This was generated with a program that took about two minutes to write
  45. and test. If this is not what your professor is looking for, let us
  46. know the remainder of the homework problem's stated constraints.
  47.  
  48. If you need hints on how to write something like this, 
  49. 'DO loop', 'READ', 'WRITE', 'FORMAT' are good hints.
  50.  
  51. If you want the program that generated the above program, email me any
  52. time after September 6.
  53.  
  54. In answer to your question about is this possible in FORTRAN, there is
  55. a general concept called a Turing Machine. You will learn about this
  56. in later classes. A simple explanation is:
  57.  
  58. " A Turing Machine (TM) is a mathematical representation of the most
  59.   powerful computer it will ever be possible to build. With the
  60.   model of a TM, you can PROVE whether certain things can or cannot
  61.   (even theoretically) be done. A computer language may be said to
  62.   be TM equivalent if it can do everything that a TM can do."
  63.  
  64. All languages that are TM equivalent can solve the same set of
  65. problems. FORTRAN, C, PASCAL, LISP (to name only a few) are all
  66. TM equivalent. Therefore, what can be done in one of them can be
  67. done in another - no more, no less.
  68.  
  69. -- 
  70. #include <Standard_Disclaimer.h>
  71. Michael F. Stemper
  72. Power Systems Consultant
  73. mstemper@ems.cdc.com
  74.