0% found this document useful (0 votes)
34 views2 pages

Info 3

The document contains 4 programs labeled P1 through P4. P1 and P2 both prompt the user to input a number n and then use a while or repeat loop to iterate from 1 to n, summing any odd numbers and outputting the final sum. P3 uses a repeat loop to continually prompt for a number i as input, then uses a for loop to output the numbers from 1 to i. P4 uses a while loop to continually prompt for a number as input until it is greater than or equal to 35, and on each iteration outputs the numbers from 1 to 34.
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)
34 views2 pages

Info 3

The document contains 4 programs labeled P1 through P4. P1 and P2 both prompt the user to input a number n and then use a while or repeat loop to iterate from 1 to n, summing any odd numbers and outputting the final sum. P3 uses a repeat loop to continually prompt for a number i as input, then uses a for loop to output the numbers from 1 to i. P4 uses a while loop to continually prompt for a number as input until it is greater than or equal to 35, and on each iteration outputs the numbers from 1 to 34.
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/ 2

Tema pentru acasă:

1) Program P1; Program P2;


var i, n, s: integer; var i, n, s: integer;
begin begin
writeln (‘n=’); readln (n); writeln (‘n=’); readln (n);
s:=0; s:=0; i:=0;
while i<=n do repeat
begin i:=i+1;
if (i mod 2 <>0) then s:=s+i; if (i mod 2 <> 0) then s:=s+i;
writeln (‘s=’,s); until i=n;
end; writeln (‘s=,s);
readln; readln;
end. end.

2)Program P3; Program P4;


var i, n: integer; var n: integer;
begin begin
writeln (‘i=’); writeln (‘n=’);
repeat while n<35 do
readln (i); begin
for n:=1 to i do writeln (n:1); readln (n);
until n=i; for n:=1 to 34 do writeln (n);
readln; end;
end. readln;
end.

You might also like