8/8/2019 Program to Find a Prime Number http://slidepdf.com/reader/full/program-to-find-a-prime-number 1/19 • Internet RFC Index • Usenet FAQ Index • Other FAQs • Documents • Tools • Search • Search FAQs • Search RFCs • Cities • Countries • Hospitals • Web Hosting Ratings [ Home | FAQ-Related Q&As | General Q&As | Answered Questions ] Search the Q&A Archives • Search Q&As write a program to find out whether a given number is prime... << Back to: comp.lang.c Answers to Frequently Asked Questions (FAQ List) Question by urvi Submitted on 1/1/2004 Related FAQ: comp.lang.c Answers to Frequently Asked Questions (FAQ List) Rating: Rate this question: write a program to find out whether a given number is prime or not. þÿ þÿ
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
This program runs, if you enter a add number that is not prime it will tell youthat it is a prime number. Any way nice try. Email me if you want 1 thatworks. ( [email protected])
Answer by KDW
Submitted on 2/19/2007
Rating: Not yet rated Rate this answer:
// This program determines the nearest prime numbers // Written in C++ // By: KDW // Febuary 1, 2007
// Several revisions are included in this edition /*1. As soon as a remainder of 0 is encountered theprogram moves on to the next incremented value aboveor below the seed.2. When testing whether a particular seed is a primethe program only test up to 1/2 of the seed value.3. Displays how many iterations were needed to producethe result.
cout << --seed << " is the nearest larger prime number!\n";cout << ++seed2 << " is the nearest smaller prime number!\n";cout << counter + counter2 << " calculations";}cout << "\nEnter another number (type '0' to quit)\n" ;cin >> seed3;cout << endl;
}return 0;
}
Answer by kiran vellanki
Submitted on 3/27/2007
Rating: Not yet rated Rate this answer:
int main(){int a,b,c,d=0;printf("Enter the number : ");scanf("%d",&a);c=a/2;
for(b=2;b<=c;b++){if (a%b==0)
++d;}
if (d==0 && a>0)printf("\n\nThe number is prime");elseprintf("\n\nThe number is not prime");
Your answer will be published for anyone to see and rate. Your answer will notbe displayed immediately. If you'd like to get expert points and benefit frompositive ratings, please create a new account or login into an existing account
below.
Your name or nickname:
If you'd like to create a newaccount or access your existingaccount, put in your passwordhere:
Your answer:
Check spelling
FAQS.ORG reserves the right to edit your answer as to improve its clarity. By submitting your answer you authorize FAQS.ORG to publish your answer on the WWW without any restrictions.You agree to hold harmless and indemnify FAQS.ORG against any claims, costs, or damagesresulting from publishing your answer.
FAQS.ORG makes no guarantees as to the accuracy of the posts. Each post is the personalopinion of the poster. These posts are not intended to substitute for medical, tax, legal,investment, accounting, or other professional advice. FAQS.ORG does not endorse any opinionor any product or service mentioned mentioned in these posts.
<< Back to: comp.lang.c Answers to Frequently Asked Questions (FAQ List)
[ Home | FAQ-Related Q&As | General Q&As | Answered Questions ]