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

find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }

1860


A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(

1743


What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?

591


What is const keyword in c?

752


What is difference between %d and %i in c?

695






hi any body pls give me company name interview conduct "c" language only

1670


What is the description for syntax errors?

616


can any one please explain, how can i access hard disk(physical address)? it is possible by the use of far,near or huge pointer? if yes then please explain......

1412


What are the types of pointers?

603


how to write a c program to print list of fruits in alpabetical order?

1792


write a c program for swapping two strings using pointer

2095


What is realloc in c?

581


What are the rules for the identifier?

674


Write a function that will take in a phone number and output all possible alphabetical combinations

606


What are the valid places to have keyword “break”?

652