write the program for prime numbers?
Answer Posted / venkat reddy
#include<stdio.h>
main()
{
int i,n,count=0;
printf("enter a no.");
scanf("%d",&n);
for(i=2;i<n;i++)
{
if(n%i==0)
{
count++;
}
}
if(count>1)
{
printf("not prime no.");
}
else
printf("prime");
}
| Is This Answer Correct ? | 344 Yes | 155 No |
Post New Answer View All Answers
Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.
Which one would you prefer - a macro or a function?
What is the difference between #include
What are the different types of data structures in c?
How can I automatically locate a programs configuration files in the same directory as the executable?
What is a global variable in c?
Multiply an Integer Number by 2 Without Using Multiplication Operator
Once I have used freopen, how can I get the original stdout (or stdin) back?
What is the difference between %d and %i?
What are header files in c?
The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none
What are local static variables?
Are pointers integer?
What is type qualifiers?
What is double pointer?