Could anyone tell me what is wrong with segmentation
of this simple code. Thanks
Regards
Kinga
--------------------------------------------------
/* The Following program searches for smallest divisor
*/
/* of a number from 1 to NMAX */
/* or determines that the number is a prime number
*/
#include <stdio.h>
#define NMAX 1000
main()
{
int i;
int n;
int min_div;
min_div = 0;
printf("\nInput a number for which program will find
smallest divisor for: ");
scanf("%d",n);
if (n<NMAX)
{
for (i=(n-1); i>1; i--)
{
if (n%i==0)
min_div=i;
}
if (min_div == 0)
printf("\n The number %d is a prime number.\n",n);
else
printf("\n The number's %d smallest divisor is
%d.\n",n,min_div);
}
else
printf("The number you have entered is beyond the
allowable range.\n");
}
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>.
| Yahoo! Groups Sponsor |
| Get unlimited calls to U.S./Canada |
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/c-prog/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
