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


Please Help Members By Posting Answers For Below Questions

.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }

2004


What is realloc in c?

581


illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question

1589


Does c have enums?

604


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

603






What is huge pointer in c?

588


Why pointers are used?

633


Are there namespaces in c?

570


What is the maximum length of an identifier?

667


Explain how do you list files in a directory?

620


What is "Hungarian Notation"?

639


What is const and volatile in c?

569


Is a house a shell structure?

699


What are high level languages like C and FORTRAN also known as?

689


What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?

815