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
Explain what are multibyte characters?
explain what is a newline escape sequence?
What is meant by keywords in c?
a value that does not change during program execution a) variabe b) argument c) parameter d) none
What is the correct declaration of main?
What is a 'null pointer assignment' error?
What is the difference between constant pointer and constant variable?
what is the significance of static storage class specifier?
Where are some collections of useful code fragments and examples?
Explain the difference between malloc() and calloc() function?
What is the purpose of realloc()?
How can you return multiple values from a function?
What are register variables? What are the advantage of using register variables?
What is clrscr in c?
Why void main is used in c?