From the course: Introduction to Fortran

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

User input

User input

- [Instructor] One of the most common things that all programs need to do is obtain input from their users. In this lesson, we'll learn about a couple of ways to do that. The first way we'll learn to get input from the user is by prompting them interactively and using the read statement. I'll demonstrate this with a program that prompts the user for their name and says, hello. So we have a program here, includes the obligatory implicit none. Then we need a variable that we're going to store the user's name in. So I've assumed that 20 characters is going to be long enough and we've called it name. Next, we want to prompt the user for what it is that they're supposed to be inputting here. Then we use a read statement with a star and a format specifier to read something. So the star is going to read the something from the terminal, the format specifier here with the parenthesis A, says it's going to be a character…

Contents