write the program for prime numbers?

Answer Posted / priyanka chauhan

// prime no series. //
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
clrscr();
printf("Enter the no: ");
scanf("%d",&n);
printf("\n");
for(i=1;i<=n;i++)
{
for(j=2;j<=i-1;j++)
{
if(i%j==0)
break;
}
if(j==i)
printf("%d ",j);
}
getch();
}

Is This Answer Correct ?    173 Yes 84 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how are 16- and 32-bit numbers stored?

773


When should a type cast be used?

570


Can you please explain the difference between syntax vs logical error?

682


Explain how do you print only part of a string?

642


In C language, a variable name cannot contain?

729






What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers

667


What is identifiers in c with examples?

665


For what purpose null pointer used?

600


What are the properties of union in c?

577


Can we change the value of #define in c?

578


How can you find out how much memory is available?

606


Explain logical errors? Compare with syntax errors.

618


develop algorithms to add polynomials (i) in one variable

1727


What is LINKED LIST? How can you access the last element in a linked list?

624


Explain high-order and low-order bytes.

658