0% found this document useful (0 votes)
53 views3 pages

Repeat I While: Radovan Brajović 1

This document contains 6 programming examples that use REPEAT and WHILE loops in Pascal to iterate through numbers and perform calculations. The examples include: 1) Printing numbers from 1 to 5 using REPEAT, 2) Printing numbers within a user-input range using REPEAT, 3) Calculating the product of numbers within a range using REPEAT, 4) Printing even numbers up to a limit using WHILE, 5) Finding the minimum of numbers input by the user using WHILE, and 6) Calculating the product of numbers divisible by a given value within a range and counting them using WHILE.

Uploaded by

Ra Ša
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views3 pages

Repeat I While: Radovan Brajović 1

This document contains 6 programming examples that use REPEAT and WHILE loops in Pascal to iterate through numbers and perform calculations. The examples include: 1) Printing numbers from 1 to 5 using REPEAT, 2) Printing numbers within a user-input range using REPEAT, 3) Calculating the product of numbers within a range using REPEAT, 4) Printing even numbers up to a limit using WHILE, 5) Finding the minimum of numbers input by the user using WHILE, and 6) Calculating the product of numbers divisible by a given value within a range and counting them using WHILE.

Uploaded by

Ra Ša
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

REPEAT I WHILE

1.

Napisati program za ispis prirodnih brojeva od 1 do 5.(REPEAT)

PROGRAM prvi;
VAR
i: INTEGER;
BEGIN
WRITELN('1 do 5');
i:=1;
REPEAT
WRITELN('i=',i );
i := i+1;
UNTIL i>5;
READLN;
END.
2. Napisati program za ispis prirodnih brojeva u intervalu od k do n. Granice intervala se
upisuju sa tastature.(REPEAT)

PROGRAM prvi;
VAR
i, k, n : INTEGER;
BEGIN
WRITELN('k-n');
WRITE('Interval');
READLN(k,n);
i:=k;
REPEAT
WRITELN('i=',i );
i := i+1;
UNTIL i>n;
READLN;
END.
3.

Nai proizvod prirodnih brojeva u intervalu od k do n, koristiti REPEAT petlju.

PROGRAM prvi;
VAR
i, n, p: Integer;
BEGIN
WRITE('Od broja ');
READLN( k );
WRITE('Do broja ');
READLN( n );
p := 1;
i := k;
REPEAT
p := p * i;
i := i + 1;
UNTIL i > n;
Radovan Brajovi

REPEAT I WHILE
Writeln('Od ', k,'do', n, 'prizvod prirodnih brojeva je
READLN;
END.

',p);

4. Napisati program za ispis parnih brojeva od 1 do n.(while)

PROGRAM prvi;
VAR
i, n: Integer;
BEGIN
Writeln('Ispis');
Write('Do broja ');
Readln(n);
i := 1;
WHILE i <= n DO
BEGIN
IF i MOD 2 = 0 THEN
Writeln(i);
i:= i + 1;
END;
END.
5. Napisati program za odrejivanje najmanjeg broja od n uitanih.(while)

PROGRAM prvi;
VAR
i: Integer;
a, min: Real;
BEGIN
WRITE('Otkcuaj 1. broj ');
READLN( a );
min := a;
i := 2;
WHILE i <= 10 DO
BEGIN
WRITE('Otkcuaj ', i, '. broj ');
READLN( a );
IF a < min THEN
min := a;
i := i + 1;
END;
Writeln('Najmanji broj je ', min);
END.

Radovan Brajovi

REPEAT I WHILE

6. Napisati program da nae proizvod prirodnih brojeva od a do b djeljivih sa l i koliko ih


ima.(WHILE)

PROGRAM PRVI;
USES
WinCrt;
VAR
i, a, b, l, br : INTEGER;
p: REAL;
BEGIN
WRITELN ('Prebroj i pomnozi delive sa l');
WRITE ('Od broja ');
READLN (a);
WRITE ('Do broja ');
READLN (b);
WRITE('Delilac ');
READLN(l);
br:=0;
p := 1;
FOR i := a TO b DO
i := a;
WHILE i <= b DO
BEGIN
IF i MOD l = 0 THEN
BEGIN
p := p * i;
br:=br+1;
END;
i := i+1;
END;
WRITELN('Proizvod prirodnih brojeva deljivih sa ', l ,'
od ', a ,' do ' , b, ' je ', p);
WRITELN('Deljivih sa ', l ,' ima ', br);
END.

Radovan Brajovi

You might also like