output - Program closes right after the last input -
so i'm trying write program school problem readln()
program closes right after last output. code, don't know problem , i've tried everything;
program calcolo; var el, ec, s, n:real; var nome:string; function returnvote(a, b, c, d:real):real; begin returnvote:= a+(2 * b) - (c / 2) - (d / 4); end; begin writeln('programma per calcolare il voto fornendo il numero di risposte esatte,'); writeln('quelle esatte e incomplete, quelle sbagliate e quelle non date'); writeln('====================================================================='); writeln('fornire il nome dello studente: '); read(nome); writeln('fornire il numero di risposte esatte e complete: '); read(ec); writeln('fornire il numero di risposte esatte ma incomplete: '); read(el); writeln('fornire il numero di risposte sbagliate: '); read(s); writeln('fornire il numero di risposte non date: '); read(n); writeln('il voto calcolato per lo studente ', nome,' e di: ', returnvote(el, ec, s, n):3:1); readln(); end.
when user inputs last number , presses enter, number written n
variable, the enter remains in buffer. when program reaches last readln()
, reads enter , exits.
to prevent this, should replace read
s readln
s (or @ least last one).
that said, it's not practice use readln
when need see program has written in output. if using old ide's turbo pascal, there menu item shows output after program terminated. modern ide's not close window, , if not using ide, can see output in console.
Comments
Post a Comment