V programe užívateľ zadá 2 čísla a program nájde odpoveď
Delphi & Pascal (česká wiki)
Kategorija: KMP (Programy mladňakoch
Program: Div_mod.pas
Subor exe: Div_mod.exe
Program: Div_mod.pas
Subor exe: Div_mod.exe
V programe užívateľ zadá 2 čísla a program nájde odpoveď.
{ DIV_MOD.PAS } { In this program user enters 2 numbers and program finds the } { answer with the reminder. } { } { Author: Unknown } { Datum: 20.01.2009 http://www.trsek.com } program Div_and_Mod; uses crt; var n1,n2,ans,ans2:integer; begin clrscr; writeln ('enter 2 numbers to be divided by each other'); writeln; writeln; readln (n1,n2); ans := n1 div n2; ans2 := n1 mod n2; writeln; writeln; if (ans2 = 0) then begin writeln ('The answer is ',ans); end else begin writeln ('The answer is ',ans,' remainder ',ans2); end; readkey; end.