write the program for prime numbers?

Answer Posted / umesh prajapati

/* find the number is prime or not prime. umesh prajapati*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,c,r;
clrscr();
printf("ENTER THE VALUE");
scanf("%d",&n);
if(n==2)
printf("THE NUMBER IS CO-PRIME");
else
{
c=2;
while(c<n)
{
r=n%c;
if(r==0)
{
printf("GIVEN NUMBER IS NOT PRIME");
break;
}
c++;
}
if(r>0)
printf("GIVEN NUMBER IS PRIME");

}
getch();
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I read a binary data file properly?

635


Where we use clrscr in c?

704


What are the advantages and disadvantages of a heap?

706


What is volatile keyword in c?

582


What’s a signal? Explain what do I use signals for?

606






What is a constant?

631


What is the difference between int main and void main?

572


What is array of structure in c?

594


What is the purpose of the following code? Is there any problem with the code? void send(int count, short *to, short *from) { /* count > 0 assumed */ register n = (count + 7) / 8; switch (count % 8) { case 0: do { *to = *from++; case 7: *to = *from++; case 6: *to = *from++; case 5: *to = *from++; case 4: *to = *from++; case 3: *to = *from++; case 2: *to = *from++; case 1: *to = *from++; } while (--n > 0); } }

1956


Why are all header files not declared in every c program?

601


Is fortran still used in 2018?

592


Explain how do you print only part of a string?

649


What are qualifiers and modifiers c?

546


can anyone suggest some site name..where i can get some good data structure puzzles???

1643


How can my program discover the complete pathname to the executable from which it was invoked?

660