|pls help write a pascal program to find the prime numbers btw 1 and 200|
pls i was given these assignment at school and i would be having a test on dis course tomorrow.pls it is very urgent.would appreciate it if any1 could help me write a pascal program to find the prime numbers between 1 and 200.
Not pascal but rexx.
do i=1 to 200
do j=1 to i until p > 2
if i // j = 0 then
if p=2 then
say i' is prime'
You didn't think anyone was going to hand it to you on a plate did you :-)
This is the fastest and smallest Pascal implementation I can think of. I don't know if they will accept it. It should be accepted though because the output of the program fits the assignment.
WriteLn( '2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,73,79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199' );
They still teach pascal? Wow.
I wrote a program like that over 20 years ago.
Just do a search in your favourite search engine for pascal prime number and I'm sure you will find some (I did, and the code was published in 1990).
But doing that defeats the purpose of doing it yourself, as you will learn things from doing it, rather than copying someone else. So if you want to actually become a programmer, try and do it yourself, or at the very least make sure you understand the code you download fully.