prime numbers using return 0 as condition - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

prime numbers using return 0 as condition

minty33minty33 Posts: 1Member
ok i know there is a million example programs to find out if entered number is prime. I want to do it a specific way and understand it at the same time. i am a complete novice as i am just learning some basic C in my unix class.
ok that all said herei s how i want to write the code

int num,div=2;
/* from here i want to run a loop that divides num by div until either return 0 is given meaning an integer( this is where what i want to do differs - i'm checking for an integer output and if an integer is returned printf("not prime") otherwise loop until div=num(although don't include div=num obviously) and if it completes all loops e.g returns 1 all the way through then printf("prime").
/*i really don't know C enough to understand the syntax of where to put the div++ and how to write - if return 0 printf("not prime") else div++ - then if it completes all loops for div=2;div<!=num printf("prime") -
i hope this makes sense any input at this point is a plus.
thanx in advanced

Sign In or Register to comment.