write the program for prime numbers?
Answer Posted / karthikeyan murugesan
hi u can try this one for prime number and generation ::
#include<stdio.h>
void main()
{
int n,i=1,j,c;
scanf("%d",&n);
while(i<=n)
{
c=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
c++;
}
if(c==2)
{
printf("%d",i);
i++;
}
}
getch();
}
Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
Explain what does the function toupper() do?
How is null defined in c?
How can I remove the leading spaces from a string?
What is the purpose of macro in C language?
In a switch statement, explain what will happen if a break statement is omitted?
What are the advantages of Macro over function?
Tell us bitwise shift operators?
What are pointers? Why are they used?
What is formal argument?
Is there anything like an ifdef for typedefs?
What is character constants?
What are register variables in c?
What is malloc calloc and realloc in c?
Give differences between - new and malloc() , delete and free() ?
Explain what is meant by 'bit masking'?