write the program for prime numbers?
Answer Posted / d.sukumar
void main()
{
int i,k;int count=0;
int n;
printf("enter a no");
scanf("%d",&n);
for(i=2;i<=n;i++)
{
k=n%i;
if(k==0)
{
count++;
}
}
if(count==1)
printf("prime");
else
printf("not prime");
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Explain the advantages and disadvantages of macros.
What are the different types of constants?
Is c procedural or object oriented?
differentiate built-in functions and user – defined functions.
State the difference between x3 and x[3].
What is .obj file in c?
What does 4d mean in c?
Can you please explain the difference between exit() and _exit() function?
Explain how can you tell whether two strings are the same?
Which is better pointer or array?
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].
What is difference between array and structure in c?
Explain the difference between malloc() and calloc() in c?
What is struct node in c?
Is printf a keyword?