Einführung in die imperative Programmierung

WS 2017/18

Geany-Einstellungen

Unter Erstellen - Kommandos zum Erstellen Konfigurieren

Hier wird auf FreePascal zurückgegriffen.

Geany Einstellungen

Einfaches Programm

{$B+} {$R+}
program SehrEinfach (output);
   {einfaches Programm}
const PI = 3.14159;
   PI2 = PI;
 
var Zahl, Zahl2, Ergebnis: integer;
   Operation : string;
begin
   write('div oder mod ');
   readln(Operation);
   write('Geben Sie eine int-Zahl ein ');
   readln(Zahl);
   write('Geben Sie eine int-Zahl ein ');
   readln(Zahl2);
   
   if Operation = 'div' then
   Ergebnis := Zahl div Zahl2
   else
   begin
   Ergebnis := Zahl mod Zahl2;
   end;
   
   writeln ('Ausgabe: ', Operation);
   writeln ('Ergebnis: ', Ergebnis);
end.
 
 


Aufgabe 4

{$B+} {$R+}

program temperatur  (input, output);
{C = [5 * (F - 32)] / 9}
var 
   Fahrenheit: real;
   Celsius : real;
BEGIN
   write('Fahrenheit eingeben');
   readln(Fahrenheit);
   
   Celsius := 5* (Fahrenheit-32) / 9;
   
   writeln('in Celsius: ', Celsius:6:0);
   
END.
 

Aufgabe 5

{$B+} {$R+}
program aufg5;
{ .... }
var 
   Cent: integer;
   c50,c20,c10,c5,c2,c1: integer;
 
begin
   {Eingabe des Betrages}
   write('Centbetrag: ');
   readln(Cent);
   
   c50 := Cent div 50;
   Cent := Cent mod 50;
   
   c20 := Cent div 20;
   Cent := Cent mod 20; 
   
   c10 := Cent div 10;
   Cent := Cent mod 10;
   
   c5 := Cent div 5;
   Cent := Cent mod 5;
   
   c2 := Cent div 2;
   Cent := Cent mod 2;
   
   c1 := Cent;
   
   writeln(c50,' ',c20,' ', c10,' ',c5,' ',c2,' ',c1);
   
end.