Thursday, May 19, 2016

Prime s in Pascal programming


The following program will display primes with pascal programming language within a certain value (in this case is limited to 100). Also accompanied by an explanation of ch step - step.









uses crt;varx, y: integer;prime: booln;beginclrscr;write ('2 ');for x: = 3 to 100 dobeginprime: = true;for y: = 2 to x-1 dobeginif (x mod y) = 0 thenbeginprime: = false;brk;end;end;if prime

No comments:

Post a Comment