Beginner C/C++

Moderators: None (Apply to moderate this forum)
Number of threads: 5428
Number of posts: 16949

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
prime numbers using return 0 as condition Posted by minty33 on 13 Oct 2012 at 12:25 PM
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;
scanf("%d",&num)
/* 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
*/




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.