Postlab05_Task2_rfelde - C = Len_Trim(String) !Create a...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
! Lab #5: Nested Loops and Arrays. ! File: Postlab05_Task2_rfelde.f95 ! Date: 07 February 2008 ! By: Ryan Robert Felde ! rfelde ! Section: 02/01, 11:30, and ENAD 138 ! Team: 16 ! ! ELECTRONIC SIGNATURE ! Ryan Robert Felde ! ! The electronic signature above indicates the program submitted for ! evaluation is my individual work and I have a general understanding ! of all aspects of its development and execution. ! ! A BRIEF DESCRIPTION OF WHAT THE PROGRAM OR FUNCTION DOES program implicit none character(len = 24) :: String character, dimension(24) :: Array1 character, dimension(6,4) :: Array integer, dimension(2) :: Shape, Pad integer, dimension(6,4) :: ASCII integer :: I, J, A, C, B, D, E !Prompt for user input of a string of 24 characters without spaces write(*,*)'Enter a string: ' !Read in the value entered read(*,*) String !Find the length of the string entered
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: C = Len_Trim(String) !Create a variable to be used later on to output the ASCII values for the entered characters E = (C/4) + 1 !Create a shape array to be used in the reshape command Shape = (/ 6 , 4 /) !Create a pad array to be used in the reshape command Pad = (/ 0 , 0 /) !Convert the string into a one dimensional array do A = 1, C Array1(A) = String(A:A) end do !Reshape the created array into the correct shape of four columns Array = reshape(Array1, Shape,Pad, (/2,1/)) !Use a do loop to calculate the ASCII value for each input character of the array do I = 1,6 do J = 1,4 ASCII(I,J) = ichar(Array(I,J)) end do end do !Use another do loop to output the corresponding ASCII value for !the input character and leave out the blank values. do B = 1,4 do D = 1, E Write(*,*)ASCII(D,B) end do end do stop end...
View Full Document

This note was uploaded on 10/05/2009 for the course ENGR 117 taught by Professor Staff during the Spring '08 term at Purdue University-West Lafayette.

Page1 / 2

Postlab05_Task2_rfelde - C = Len_Trim(String) !Create a...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online