| | |
!!! Help ME !!!!!
Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
![]() |
ok so im in college right computer science major first year and all and they still have pascal can you believe it wow so ne ways he gives out this assingment and the assingment is this i need to write a programm using delphi ythat would be able to name a prime number or a non prime number from 1 to 1000 and it needs to open the window when ran to ask you for a number and you enter a number press enter then it needs to decifer if it is a prime number or a non prime number i need help ANYONE PLEASE HELP!!!!
•
•
Join Date: Dec 2006
Posts: 171
Reputation:
Solved Threads: 16
so, you think that pascal is old fashion, and you want to use delphi(you got charmed probably about drag-drop,click and the program is finished) but you aren't able to find if a number is prime or not?
what you have done until now? post some code of what you accomplished and we'll help you.
best regards,
what you have done until now? post some code of what you accomplished and we'll help you.
best regards,
•
•
Join Date: Dec 2006
Posts: 171
Reputation:
Solved Threads: 16
SysUtils;
{$APPTYPE CONSOLE}
// the start of the function
Function Prime
// the begging of thine main program
var
num : integer;
begin
writeln(' Enter a number from 1 to 1000 and push enter ');
readln(num);
end.
this is the entire code i have found in your file! what i think? well, you made an console application which is showing a text on screen, and read an integer from keyboard.
in that file it is explained very well which is the mecanism of finding a prime number! you don't know how to implement the procedure/function or what?
best regards,
{$APPTYPE CONSOLE}
// the start of the function
Function Prime
// the begging of thine main program
var
num : integer;
begin
writeln(' Enter a number from 1 to 1000 and push enter ');
readln(num);
end.
this is the entire code i have found in your file! what i think? well, you made an console application which is showing a text on screen, and read an integer from keyboard.
in that file it is explained very well which is the mecanism of finding a prime number! you don't know how to implement the procedure/function or what?
best regards,
•
•
Join Date: Dec 2006
Posts: 171
Reputation:
Solved Threads: 16
•
•
•
•
in way i do and it sounds like your bashing me and i said i needed help starting it thats what i said man and open up the other one thats there too above the one you opened so you know i know what im doing and btw man im not a top flight programmer thats why im here
code:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
function prime(number:integer):string;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption:=prime(strtoint(edit1.Text));
end;
function TForm1.prime(number:integer): string;
var i:integer;
prime:boolean;
begin
Label1.Caption:='';
prime:=true;
result:='prime';
if (number=1) or (number=2) or (number=3) then prime:=true
else
for i:=2 to round(sqrt(number)) do
if number mod i=0 then
begin
prime:=false;
result:='not prime';
exit;
end;
end;
end.
hope you'll try to understand this program, not only to copy it and past it.
best regards,
Last edited by radu84; Mar 28th, 2007 at 4:00 pm.
![]() |
Other Threads in the Pascal and Delphi Forum
- Previous Thread: 'Database is not in insert or edit mode'
- Next Thread: Importing TLB Files
| Thread Tools | Search this Thread |
Tag cloud for Pascal and Delphi





