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

What is self-referential structure in c programming?

662


Explain about C function prototype?

613


What is the use of c language in real life?

533


What does %c mean in c?

656


Explain what are the standard predefined macros?

655






Differentiate between #include<...> and #include '...'

619


What are global variables and how do you declare them?

623


How #define works?

623


GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)

686


Why main is not a keyword in c?

652


What is a union?

611


What is the significance of an algorithm to C programming?

598


What is oops c?

615


pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)

1865


Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.

2657