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 do you use macro?

665


What does %p mean?

588


Why is c called a mid-level programming language?

720


What are operators in c?

575


Explain About fork()?

640






What will the preprocessor do for a program?

584


What is the 'named constructor idiom'?

636


What is the use of define in c?

590


any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()

691


How can a string be converted to a number?

512


Explain how can you check to see whether a symbol is defined?

655


Write a program to check palindrome number in c programming?

596


Explain what is the most efficient way to store flag values?

692


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

670


What is the scope of local variable in c?

572