السلام عليكم
اتمنى من المختصين المساعده
في عندي برنامج عشان يطلع لي الاعداد الصحيحه
هذا الكود حق البرنامج
//---------------------------------------------------------------------------
#include <vcl.h>
#include "MT262io.h"
#pragma hdrstop
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
char Another;
int Test;
int Factor;
bool Prime;
Another = 'Y';
Prime = true;
while (Another == 'Y')
{
Test = ReadIntPr("Enter number to be tested .. ");
Factor = 2;
while (Factor < Test )
{
if (Test%Factor == 0)
Prime = false;
Factor = Factor + 1;
}
WriteInt(Test);
if (Prime == true)
WriteStringCr(" is prime") ;
else
WriteStringCr(" is not prime");
Another = ReadCharPr("Type Y to test another number .. ");
}
getchar();
return 0;
}
//---------------------------------------------------------------------------
بحيث اني
During testing the student realised that something was wrong with the program
design because a program run reported, correctly, that 15 is not a prime but went
on to report, incorrectly, that 17 is also not a prime.
شنو الحل :(