File: sphere.f

package info (click to toggle)
preprocess 1.1.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch, wheezy
  • size: 472 kB
  • ctags: 218
  • sloc: python: 1,640; cpp: 260; makefile: 31; fortran: 24
file content (37 lines) | stat: -rw-r--r-- 1,015 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
c23456789012345678901234567890123456789012345678901234567890123456789012

      PROGRAM sphere

c  This program determines the surface area and volume of a sphere, given 
c  its radius.

c  Variable declarations
      REAL  rad, area, volume, pi

c  Definition of variables
c   rad = radius, area = surface area, volume = volume of the sphere

c  Assign a value to the variable pi.
      pi = 3.141593

c  Input the value of the radius and echo the inputted value.
      PRINT *, 'Enter the radius of the sphere.'
      READ *, rad
      ! #define VERBOSE 1
C  #if VERBOSE
      PRINT *, rad, ' is the value of the radius.'
!  #endif

c  Compute the surface area and volume of the sphere.
      area = 4.0 * pi * rad**2
      volume = (4.0/3.0) * pi * rad**3

c  Print the values of the radius (given in cm), the surface area (sq cm),
c  and the volume (cubic cm).
      PRINT *,'In a sphere of radius', rad, ' , the surface area is',
     +          area, ' and its volume is', volume, '.'
      STOP

      END