Hi,
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

Web Bug from http://view.atdmt.com/VON/view/yhxxxvon01900091von/direct/01/&time=1099938842664434
Web Bug from http://us.adserver.yahoo.com/l?M=281955.5530326.6602771.3001176/D=groups/S=:HM/A=2343726/rand=420234097


Yahoo! Groups Links

Reply via email to