simple f77 prog - need help
Author Message simple f77 prog - need help

I need help with a program that accepts as input
an integer m.
It should then draw a complete cycle of a sine
wave that
is plotted in a grid of   m (rows)   by m (cols)
and is scaled to fit the grid.  are repeated).
Examples:

for m=20, you would plot:
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
for m=10, you would plot:
x
x
x
x
x
x
x
x
x
x
for m=7, you would plot:
x
x
x
x
x
x
x
for m=2, you would plot:
x
x
Allow m to be as large as 100.

Sent via Deja.com http://www.*-*-*.com/
Share what you know. Learn what you don't.

Wed, 18 Jun 1902 08:00:00 GMT  simple f77 prog - need help

Quote:

> I need help with a program

Try the following, moving all the "declarative" statements to follow
the 'PROGRAM' statement, and moving the 'DATA' statement
to precede the first executable statement.

Indent to column 7, if you are using "fixed-format" source-input.

PROGRAM HOMEWORK

Quote:
> that accepts as input an integer m.
> Allow m to be as large as 100.

INTEGER M
IF (M .LT. 1) STOP
IF (M .GT. 100) STOP

Quote:
> It should then draw a complete cycle of a sine wave

REAL PI
DATA PI/3.14159265359/

Quote:
> that is plotted in a grid of   m (rows)   by m (cols)

REAL X, Y, Z

X = 0
Z = 2.0 * PI / FLOAT(M)  ! One full cycle, divided into M parts,
starting at "zero"

INTEGER J,K,N

DO 100  J=0,M   ! Plot each row, and one extra row.

Y = (SINE(X)+1.0)/2.0     ! Convert (-1,1) to (0,1) range
X = X + Z ! Increment X

CHARACTER*1 BLANK,STAR
BLANK= ' '
STAR='*'

Quote:
> and is scaled to fit the grid.

K = INT(FLOAT(M)*Y)

WRITE (*,*) (BLANK,N=1,K), STAR

100       CONTINUE

END

Wed, 18 Jun 1902 08:00:00 GMT  simple f77 prog - need help
Gee, I have a whole bunch of homework; will you do mine, too?

Thanks,
fc
--

Quote:

> > I need help with a program

> Try the following, moving all the "declarative" statements to follow
> the 'PROGRAM' statement, and moving the 'DATA' statement
> to precede the first executable statement.

> Indent to column 7, if you are using "fixed-format" source-input.

> PROGRAM HOMEWORK

> > that accepts as input an integer m.
> > Allow m to be as large as 100.

> INTEGER M
> IF (M .LT. 1) STOP
> IF (M .GT. 100) STOP

> > It should then draw a complete cycle of a sine wave

> REAL PI
> DATA PI/3.14159265359/

> > that is plotted in a grid of   m (rows)   by m (cols)

> REAL X, Y, Z

> X = 0
> Z = 2.0 * PI / FLOAT(M)  ! One full cycle, divided into M parts,
> starting at "zero"

> INTEGER J,K,N

> DO 100  J=0,M   ! Plot each row, and one extra row.

> Y = (SINE(X)+1.0)/2.0     ! Convert (-1,1) to (0,1) range
> X = X + Z ! Increment X

> CHARACTER*1 BLANK,STAR
> BLANK= ' '
> STAR='*'

> > and is scaled to fit the grid.

> K = INT(FLOAT(M)*Y)

> WRITE (*,*) (BLANK,N=1,K), STAR

> 100       CONTINUE

> END

Wed, 18 Jun 1902 08:00:00 GMT  simple f77 prog - need help

Quote:
> Gee, I have a whole bunch of homework; will you do mine, too?

Yes.  Thanks for asking.

Just E-mail me, including your credit-card number and expiry, for my
fee schedule.

Quote:

> Thanks,
> fc
> --

> > > I need help with a program

> > Try the following, moving all the "declarative" statements to follow
> > the 'PROGRAM' statement, and moving the 'DATA' statement
> > to precede the first executable statement.

> > Indent to column 7, if you are using "fixed-format" source-input.

> > PROGRAM HOMEWORK

> > > that accepts as input an integer m.
> > > Allow m to be as large as 100.

> > INTEGER M
> > READ(*,*) M
> > IF (M .LT. 1) STOP
> > IF (M .GT. 100) STOP

> > > It should then draw a complete cycle of a sine wave

> > REAL PI
> > DATA PI/3.14159265359/

> > > that is plotted in a grid of   m (rows)   by m (cols)

> > REAL X, Y, Z

> > X = 0
> > Z = 2.0 * PI / FLOAT(M)  ! One full cycle, divided into M parts,
> > starting at "zero"

> > INTEGER J,K,N

> > DO 100  J=0,M   ! Plot each row, and one extra row.

> > Y = (SINE(X)+1.0)/2.0     ! Convert (-1,1) to (0,1) range

Did you notice the extra 'E' in the above line?   :-)

- Show quoted text -

Quote:
> > X = X + Z ! Increment X

> > CHARACTER*1 BLANK,STAR
> > BLANK= ' '
> > STAR='*'

> > > and is scaled to fit the grid.

> > K = INT(FLOAT(M)*Y)

> > WRITE (*,*) (BLANK,N=1,K), STAR

> > 100       CONTINUE

> > END

Wed, 18 Jun 1902 08:00:00 GMT

 Page 1 of 1 [ 4 post ]

Relevant Pages