Pages

Tuesday, October 23, 2012

How to find all prime number between a range.

# A program to print all prime  numbers between-10 to 100.

  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. int i,n,f,rang,c;
  6. clrscr();
  7. for(n=10;n<=100;n++){
  8. f=0;
  9. for(i=2;i<n;i++)
  10. if(n%i==0){
  11. f=1;
  12. break;}

  13. if(f==0)
  14. printf("%d ",n);
  15. else
  16. printf(" ");
  17. }
  18. getch();
  19. }

RULES & output:
1.Program type:used by for loop and if else.
2.Simple input:10-100
3.Simple output:11 13 17 19 23 ………………97.

No comments:

Post a Comment