I'm a third year irregular CS student and ,i just realized that i have to start coding.
I passed my coding classes with lower bound grades so that i haven't a good background in coding&programming.
I'm trying to write a code that generates prime numbers between given upper and lower bounds. Not knowing C well, enforce me to write a rough code then go over it to solve. I can easily set up the logic for intended function but i probably create a wrong algorithm through several different ways.
Here I share my last code, i intend to calculate that when a number gives remainder Zero , it should be it self and 1 , so that count==2; What is wrong with my implementation and with my solution generating style? I hope you will warm me up to programming world, i couldn't find enough motivation and courage to get deep into programming. Thanks in Advance :)
Stdio and Math.h is Included
int primegen(int down,int up)
{
int divisor,candidate,count=0,k;
for(candidate=down;candidate<=up;candidate++)
{
for(divisor=1;divisor<=candidate;divisor++)
{
k=(candidate%divisor);
}
if (k==0) count++;
if(count==2)
{
printf("%d\n", candidate);
count=0;
}
else
{
continue;
}
}
}
int main()
{
primegen(3,15);
return 0;
}