C PROGRAMMING

write a c program to print prime numberes upto a given value/number

#include<stdio.h>
int main()
{
int n,i,fact,j;
printf("Enter the lemit upto you want to print prime numbersnn");
scanf("%d",&n);
printf("nPrime Numbers are: n");
for(i=1; i<=n; i++)
{
fact=0;
for(j=1; j<=n; j++)
{
if(i%j==0)
fact++;
}
if(fact==2)
printf("%d " ,i);
}
return 0;
}

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button