To Display Prime Numbers From m to n

//To Display Prime numbers from m to n


**********************
www.botskool.com
**********************

#include<stdio.h>
#include<ctype.h>
#include<conio.h>
void main()
{
 int j,fact ;
 char ch;
 long int m, n,i;
  clrscr();
do
{
 printf("\nEnter the number From which you want to add prime number: " );
 scanf("%ld",&m);
 printf("\nUpto which number: ") ;
 scanf("%ld",&n);
 clrscr();
 printf("\nPrime nos. between %ld to %ld are:\n",m,n);

 for(i=m;i<=n;i++)
 {fact=0;
 for(j=1;j<=i;j++)
 {
 if (i%j==0)
 fact++;
 }
 if(fact==2)
 printf(" %d ",i);

 }

 printf("\n\n\nRe-enter(y/n)?");
 ch=getch();
 }while(tolower(ch)!='n');

 getch();
}
/*
**********************
www.botskool.com
**********************

Output

 

 

Download Source Code

 

Terms of Agreement: 
By using this code, you agree to the following terms- 
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge. 
2) You MAY NOT redistribute this code (for example to a web site) without written permission from us. Failure to do so is a violation of copyright laws. 
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame.
4) You will abide by any additional copyright restrictions which may have placed in the code or code's description.
 
 

Tags:

Comments

Member since:
18 February 2009
Last activity:
6 hours 49 min

Hi kswathionline,

It should be - 

#include <stdio.h>
void main()
{
printf("Hello World");
}

Member since:
24 March 2010
Last activity:
18 weeks 2 days

#include<stdio.h>

void main()

[

printf("Hello World");

]