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


Please Help Members By Posting Answers For Below Questions

Which is better pointer or array?

597


write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?

2413


How does pointer work in c?

621


What is a floating point in c?

604


How do you determine a file’s attributes?

602






What does %p mean c?

630


write a program to find the given number is prime or not

3845


What is c preprocessor mean?

793


why do some people write if(0 == x) instead of if(x == 0)?

654


Explain modulus operator.

597


Where is c used?

648


What is meant by initialization and how we initialize a variable?

587


What does c value mean?

628


How do you define structure?

567


Find MAXIMUM of three distinct integers using a single C statement

624