program SumOfNumbers;
varnum, i, sumEven, sumOdd, totalSum: integer;
beginsumEven := 0;sumOdd := 0;totalSum := 0;
writeln('Enter a natural number: ');readln(num);
for i := 1 to num dobeginif i mod 2 = 0 thensumEven := sumEven + ielsesumOdd := sumOdd + i;
end;
writeln('Sum of even numbers: ', sumEven);writeln('Sum of odd numbers: ', sumOdd);writeln('Total sum of numbers: ', totalSum);
end.
program SumOfNumbers;
var
num, i, sumEven, sumOdd, totalSum: integer;
begin
sumEven := 0;
sumOdd := 0;
totalSum := 0;
writeln('Enter a natural number: ');
readln(num);
for i := 1 to num do
totalSum := totalSum + i;begin
if i mod 2 = 0 then
sumEven := sumEven + i
else
sumOdd := sumOdd + i;
end;
writeln('Sum of even numbers: ', sumEven);
writeln('Sum of odd numbers: ', sumOdd);
writeln('Total sum of numbers: ', totalSum);
end.