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

How can I delete a file?

840


What is pointer and structure in c?

783


Why is c called a mid-level programming language?

964


What does c mean in standard form?

866


Write the control statements in C language

878


Explain what are compound statements?

825


how should functions be apportioned among source files?

874


What does main () mean in c?

866


Why c is procedure oriented?

793


what is the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555

2803


What is the benefit of using an enum rather than a #define constant?

944


Difference between Shallow copy and Deep copy?

1796


What are unions in c?

787


Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor

3252


What are the modifiers available in c programming language?

992