Welcome to the new platform of Programmers 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 it's 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
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
/* 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