write a program for prime numbers between 1 to 100
#include<stdio.h>
#include<conio.h>
int main()
{
int num,i,count;
for(num = 1;num<=100;num++)
{
count = 0;
for(i=2;i<=num/2;i++)
{
if(num%i==0)
{
count++;
break;
}
}
if(count==0 && num!= 1)
printf("%d ",num);
}
return 0;
}
Output:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
#include<stdio.h>
#include<conio.h>
int main()
{
int num,i,count;
for(num = 1;num<=100;num++)
{
count = 0;
for(i=2;i<=num/2;i++)
{
if(num%i==0)
{
count++;
break;
}
}
if(count==0 && num!= 1)
printf("%d ",num);
}
return 0;
}
Output:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
No comments:
Post a Comment