Answered # Please help me again

FlamingClaw 98

0

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.

Recommended Articles

Hi,

I am creating a program that when you print an author, you must show all the information of all the books that the author has written. Add a new attribute in the Author class that will be "BooksWriting: List (Book)".

I have expanded the program so that it also ...

I am currently creating a simulation of a pizza ordering system in object oriented program. I have some question. the instruction and guideline is long but I will try and cut it down a lot. the instruction is to create a program that simulate a pizza restaurant using ...

```
#include <stdio.h>
int main(void)
int movieChoice;
int seatNum;
int seatPlan[5][10] = { 0 };
int rows, cols;
char space;
void seatDisplay(int a[][10]);
void seatNew(int n[][10]);
void seatDisplay(int a[][10]) { //this function shows the seat plan
for (int i = 0; i<5; i++) {
for (int j = 0; j<10; j++) ...
```