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
Why c is a procedural language?
Hi how many types of software editions are there and their difference (like home editions, enterprise, standard etc) can u please help me
Why clrscr is used after variable declaration?
What is the most efficient way to count the number of bits which are set in an integer?
Here is a good puzzle: how do you write a program which produces its own source code as output?
How to write a code for reverse of string without using string functions?
What is the time and space complexities of merge sort and when is it preferred over quick sort?
Place the #include statement must be written in the program?
Why does the call char scanf work?
How can I sort more data than will fit in memory?
What is the best way to store flag values in a program?
What is the size of enum in bytes?
general for is %wd,f-d; in this system "w" means a) 'w' represent total width of digits b) 'w' represent width which includes the digits before,after decimal place and the decimal point c) 'w' represent width which includes the digits before only d) 'w' represent width after decimal place only
What is use of bit field?
What is multidimensional arrays