write the program for prime numbers?

Answer Posted / nitesh sanwal

#include<stdio.h>
#include<math.h>
void main()
{
int n,i,prime=1;
printf("input the numbers");
scanf("%d",&n);
for(i=2;i<=sqrt(n);i++)
if(n%i==0)
{
prime=0;
break;
}
if(prime)
printf("%d is a prime number",n);
else
printf("%d is a not a prime number",n);
}

Is This Answer Correct ?    6 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are c identifiers?

627


What are the different types of data structures in c?

601


Explain what are binary trees?

607


What is unsigned int in c?

556


What is the size of structure pointer in c?

613






What is 'bus error'?

644


i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical

1842


c program to compute AREA under integral

1808


What is the right way to use errno?

619


What is scope of variable in c?

562


What standard functions are available to manipulate strings?

560


What are the application of void data type in c?

704


What is the use of function overloading in C?

677


What is the process to generate random numbers in c programming language?

608


What Is The Difference Between Null And Void Pointer?

639