Displaying prime numbers between two inputs using recursion
I HAVE THIS CODE HERE BUT IT DOESNT WORK. SOMEONE HELP
void display(int x, int y);
int divider=2, z, remainder;
void main()
{
int igit, tobol;
clrscr();
printf("Input first number: ");
scanf("%i", igit);
printf("Input second number: ");
scanf("%i", tobol);
display(igit, tobol);
getch();
}
void display(int x, int y)
{
if(x<y)
{
z=x+1;
remainder=z%divider;
if(remainder==0&&z!=divider)
{
divider=divider+1;
display(x,y);
}
if(z==divider)
{
printf("%i", z);
x++;
divider=2;
display(x,y);
}
else
{
divider++;
display(x,y);
}
}
}
display(x,y) is to call the program again. i've set the divider to 2 so
that it starts at two when looking for the modulo
No comments:
Post a Comment