write the program for prime numbers?

Answer Posted / paps

#include<stdio.h>
void main()
{
int a=1,i,j,b,n;
printf("enter the range\n");
scanf("%d",&n);
printf("prime number series between 1 to %d:n");
printf("%d",a);
while(i<=n)
{
for(j=2;j<i;j++)
{
b=i%j;
if(b==0)
break;
}
if(i==j)
printf("%d",i);
i++;
}
getch();
}

Is This Answer Correct ?    8 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Should I learn data structures in c or python?

589


How can I handle floating-point exceptions gracefully?

638


Why is event driven programming or procedural programming, better within specific scenario?

1955


What 'lex' does?

723


Is fortran still used today?

609






What does it mean when a pointer is used in an if statement?

608


What is wrong with this statement? Myname = 'robin';

828


write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays

1790


When a c file is executed there are many files that are automatically opened what are they files?

598


How can I generate floating-point random numbers?

613


What is the difference between near, far and huge pointers?

630


Explain the use of function toupper() with and example code?

660


Why malloc is faster than calloc?

594


What is scope of variable in c?

573


Are pointers integers in c?

615