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 c programming structure?

804


What are the 4 types of functions?

766


Can the “if” function be used in comparing strings?

758


C program to find all possible outcomes of a dice?

2040


Is there sort function in c?

773


How will you declare an array of three function pointers where each function receives two ints and returns a float?

1018


Why & is used in scanf in c?

794


Write a program in c to replace any vowel in a string with z?

865


What functions are used for dynamic memory allocation in c language?

832


What is the difference between text and binary i/o?

758


By using C language input a date into it and if it is right?

785


What are the types of bitwise operator?

821


The postoder traversal is 7,14,3,55,22,5,17 Then ur Inorder traversal is??? please help me on this

3236


Why does everyone say not to use gets?

792


typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none

949