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
How can I read a binary data file properly?
Where we use clrscr in c?
What are the advantages and disadvantages of a heap?
What is volatile keyword in c?
What’s a signal? Explain what do I use signals for?
What is a constant?
What is the difference between int main and void main?
What is array of structure in c?
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); } }
Why are all header files not declared in every c program?
Is fortran still used in 2018?
Explain how do you print only part of a string?
What are qualifiers and modifiers c?
can anyone suggest some site name..where i can get some good data structure puzzles???
How can my program discover the complete pathname to the executable from which it was invoked?