Code:#include<conio.h> #include<stdio.h> void main(void) { int num,i; clrscr(); for(num=1;num<=300;num++) { for(i=1;i<=num;i++) { if(i!=1 && i!=num && num%i==0) break; else if(i<num) continue; else printf("%4d",num); } } }
Code:#include<conio.h> #include<stdio.h> void main(void) { int num,i; clrscr(); for(num=1;num<=300;num++) { for(i=1;i<=num;i++) { if(i!=1 && i!=num && num%i==0) break; else if(i<num) continue; else printf("%4d",num); } } }
Again, do you have a question?
The inner loop is over-complicated (simplest would be to call a function like is_prime and implement that more simply) and 1 is not a prime.
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
Maybe the OP is shy?
You've got a void main. You should alway use int main.
Also, you might want to google Sieve of Eratosthenes, it's a neat algorithm for finding prime numbers.
QuantumPete
"No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
"Have you tried turning it off and on again?" - The IT Crowd