write the program for prime numbers?
Answer Posted / ankish jaiswal
#include<stdio.h>
#include<conio.h>
int main()
{
int r,a,b,c=0;
printf("Enter the n value:");
scanf("%d",&r);
a=0;
while(a<=r)
{
b=1;c=0;
while(b<=a)
{
if(a%b==0)
c=c+1;
b++;
}
if(c==2)
printf("%d ",a);
a++;
}
getch();
return 0;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is unary operator?
What is getche() function?
Who developed c language?
Why do we need functions in c?
What are the advantages of c preprocessor?
Why is c not oop?
What does double pointer mean in c?
the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?
write a program to display all prime numbers
What is selection sort in c?
Why c is called a mid level programming language?
Is it possible to initialize a variable at the time it was declared?
Is it cc or c in a letter?
What are the key features in c programming language?
What tq means in chat?