A positive integer is entered from the keyboard. If it's even, all even integers from 2 up to and includng the entered integer are displayed. If odd, all odd integers from 1 up to and including the entered integer are summed, and the sum displayed.

Please help me again.

Hi
I wrote a solution for your problem in Pascal

{Question:
A positive integer is entered from the keyboard.
 If it's even, all even integers from 2 up to
 and includng the entered integer are displayed.
 If odd, all odd integers from 1 up to
 and including the entered integer are summed,
 and the sum displayed.
 }
Program Program01;
Uses Crt;
{we need two variables}
Var TheNumber:Integer;{entered number}
    i:Integer;        {for loop}

{procedure for even}
Procedure EvenNumbers(EN01:Integer);
   Begin
     WriteLn(EN01,' is an even number!');
     For i:=1 To EN01 Do
        Begin
          If (i Mod 2 = 0) Then
          Write(i,' ');
        End;
   End;
{procedure for odd}
Procedure OddNumbers(ON01:Integer);
   Begin
      WriteLn(ON01,' is an odd number!');
      For i:=1 To ON01 Do
         Begin
            If (Odd(i))Then
            Write(i,' ');
         End;
   End;

Begin {main}
     Write('Give me the  positive number: ');
     ReadLn(TheNumber);{catch it}
     Case Odd(TheNumber) Of    {analize it}
        True:OddNumbers(TheNumber); {if true,call OddNumbers() procedure}
        False:EvenNumbers(TheNumber); {if false then call the other one}
     End;
     ReadKey;
End.
{
-= Note By FlamingClaw =-
-=Odd(x)=- -=System Unit=-
Tests if the argument is an odd number.
Declaration:
function Odd(X: Longint): Boolean;
Target:Windows, Real, Protected
Remarks:True, if X is an odd number.
*** *** *** *** *** *** *** *** *** *** *** *** *** ***
-=y Mod x=-
If y Mod x = 0 Then y divisible by x without reminder
y:=5;
x:=3;
z:= y Mod x;     5 Mod 3 = 2  there is reminder
Mod always shows the remainder!

All programs created by me  are written and tested in 
Dev Pascal and/or Turbo Pascal 7.0

-= Created By FlamingClaw =-
-=2009.03.26=-
}
This question has already been answered. Start a new discussion instead.