#include <stdio.h>
#include <conio.h>
void main()
{
int a[100],i,j=2;
clrscr();
for(i=0;i<100;i++)
a[i]=i+1;
printf("Prime Number between 1 to 100 \n");
for(i=0;i<100;i++)
{
for(j=2;a[i]>j;j++)
{
if(a[i]%j==0)
break;
}
if(a[i]==j || a[i]==1)
printf("%d\t",a[i]);
}
getch();
}
Subscribe to:
Post Comments (Atom)
Related Post
Array:
String functions:
General (Loops-for/while)
thanks for post this it is great
ReplyDeletea[100] and a[i] represent what?????
Deletethx ya..
ReplyDeletehelped complete ma assignment.(chuckle
:P)
#include
ReplyDeleteint isPrime(int);
int main()
{
int num,prime;
printf("Enter range : ");
scanf("%d",&num);
for(int i=2; i<num; i++)
{
prime = isPrime(i);
if(prime == 1)
{
printf("%d ",i);
}
}
return 0;
}
int isPrime(int num)
{
int i=2;
while(i <= num-1)
{
if(num%i ==0)
{
return 0;
}
i++;
}
if(i == num)
return 1;
return 1;
}
#include
ReplyDelete#include
void main()
{
int c,d=0,e=0,i,j;
for(i=1;i<=100;i++)
{
j=(i/2);
for(j;j>1;j--)
{
c=i%j;
if(c==0)
{
d++;
break;
}
else
{
}
}
if(d==0)
{
e++;
printf("\n%d", i);
}
d=0;
}
printf("\n\ntotal %d prime no.s\n\n", e);
}
ReplyDeleteBest way to find prime numbers in C | Sieve Of Erasthothanese method to generate prime numbers |
#include
ReplyDeletevoid main()
{
int i,j,num;
printf("enter a number");
scanf("%d",&num);
for(i=2;i<num;i++)
{
if(num%i==0){
printf("not a prime number");
}else{
printf("prime number");
}break;
}
}
i think this one is easier than others!! thanks
Awsome Thnks A lot....
ReplyDeleteExcellent explanation by admin
ReplyDeleteprogram for Print Prime numbers from 1 to n
Easiest Program to Find Whether Given Number Is Prime Number Or Not
ReplyDeleteGood
ReplyDeleteHere is a link for C/C++ programs and pointer programs. This may be useful for you.
C Programs
C++ Programs
Its very easy only practise
ReplyDeletePrime number program in C
ReplyDeleteThanks for this post
good work programming
ReplyDeletegood work programming
ReplyDeleteA prime number is a whole number greater than 1, which is only divisible by 1 and itself. First few prime numbers are : 2 3 5 7 11 13 17 19 23
ReplyDelete2 is the only even Prime number. Prime number program in C++. Every prime number can represented in form of 6n+1 or 6n-1, where n is natural number. 2, 3 are only two consecutive natural numbers which are prime too.
I want to buy your blog call me 8076671483
ReplyDeletehitesh.xc@gmail.com