Write a program to find whether the given number is prime or
not?
Answer Posted / sudha
#include<stdio.h>
#include<conio.h>
void main()
{
int isprime=1;
int n,i;
printf("enter a number");
scanf("%d",&n);
if(i=2;i<=n/2;i++)
{
if((n%i)==0)
{
isprime=0;
break;
}
}
if(isprime==1)
{
printf("%d is a prime number",n);
}
else
{
printf("%d is not a prime number",n);
}
getch();
}
| Is This Answer Correct ? | 18 Yes | 5 No |
Post New Answer View All Answers
Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?
What is c variable?
Explain what is the purpose of "extern" keyword in a function declaration?
What does *p++ do? What does it point to?
What language is c written?
Give the rules for variable declaration?
What is function definition in c?
Is register a keyword in c?
Explain the difference between ++u and u++?
What is array of pointers to string?
What is the stack in c?
What are reserved words?
When would you use a pointer to a function?
What is a program?
a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none