Calculating Prime Numbers upto Given Number

Spread the love

Program

#include<stdio.h>
main()
{
int n,i,j,cnt=0;
printf(“Enter Any No :”);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
cnt = 0;
for(j=2;j<i;j++)
{
if(i%j == 0)
cnt++;
}
if(cnt == 0)
{
printf(“%d “,i);
}
}
}

/********** OUTPUT *********/


Venkatesh Macha

Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.

You may also like...

Leave a Reply