Skip to content
Snippets Groups Projects
Commit 969b2031 authored by Felix Hilsky's avatar Felix Hilsky
Browse files

variablenbenennung gefixt

parent d2cef6c7
Branches
No related tags found
No related merge requests found
......@@ -35,7 +35,7 @@ Nach Ausführung des Unterprogramms soll berechneter (eingegebener) Wert im Haup
Option 1 mit subroutine:“
PROGRAM
SUBROUTINE namenseingabe(eingabeaufforderung, benutzereingabe)
SUBROUTINE anzahleingabe(eingabeaufforderung, benutzereingabe)
CHARACTER(len = *), INTENT(IN) :: eingabeaufforderung ! len = * -> übernommene Länge
INTEGER, INTENT(OUT) :: benutzereingabe ! voriger Wert des Arguments wird ignoriert
......@@ -58,15 +58,15 @@ man gibt Argumente rein, bekommt Ergebnis raus
damit kann man weiterrechnen, z.B. mittelwert = REAL(summe)/n (in Zyklus Programm)
Das Ergebnis nennt man "Rückgabewert"“
FUNCTION namenseingabe(eingabeaufforderung)
FUNCTION anzahleingabe(eingabeaufforderung)
CHARACTER(len = *), INTENT(IN) :: eingabeaufforderung ! len = * -> übernommene Länge
INTEGER :: namenseingabe ! innerhalb der Funktion ist eingabe eine
INTEGER :: anzahleingabe ! innerhalb der Funktion ist eingabe eine
! normal nutzbare Variable, bekommt einen Typ
DO
WRITE(*,*) eingabeaufforderung
READ (*,*) namenseingabe
IF (namenseingabe > 0) THEN
READ (*,*) anzahleingabe
IF (anzahleingabe > 0) THEN
EXIT
ELSE
WRITE(*,*) "Eingabe fehlerhaft. Bitte nochmal."
......@@ -106,15 +106,15 @@ MODULE simpleIO
CONTAINS
FUNCTION namenseingabe(eingabeaufforderung)
FUNCTION anzahleingabe(eingabeaufforderung)
CHARACTER(len = *), INTENT(IN) :: eingabeaufforderung ! len = * -> übernommene Länge
INTEGER, (KIND=intkind) :: namenseingabe ! innerhalb der Funktion ist eingabe eine
INTEGER, (KIND=intkind) :: anzahleingabe ! innerhalb der Funktion ist anzahleingabe eine
! normal nutzbare Variable, bekommt einen Typ
DO
WRITE(*,*) eingabeaufforderung
READ (*,*) namenseingabe
IF (eingabe > 0) THEN
READ (*,*) anzahleingabe
IF (anzahleingabe > 0) THEN
EXIT
ELSE
WRITE(*,*) "Eingabe fehlerhaft. Bitte nochmal."
......@@ -132,7 +132,7 @@ PROGRAM testprog
INTEGER :: n
n = eingabe("Hallo, gib eine Zahl ein.")
n = anzahleingabe("Hallo, gib eine Zahl ein.")
END PROGRAM
„beim Kompilieren muss beides kompiliert werden, das Modul allerdings
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment