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
Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
What are runtime error?
What are external variables in c?
Is it better to bitshift a value than to multiply by 2?
How can I ensure that integer arithmetic doesnt overflow?
Explain how can type-insensitive macros be created?
What is the difference between printf and scanf )?
Describe explain how arrays can be passed to a user defined function
Explain what is the concatenation operator?
Write a program to print ASCII code for a given digit.
What is quick sort in c?
What is getch () for?
How many types of arrays are there in c?
How can you avoid including a header more than once?
When can you use a pointer with a function?