/*=================================================================================
**
** File Name : primePrint.c
** Creation Date : Sat 19 Mar 2016 05:08:00 AM IST
** Last Modified : Sat 19 Mar 2016 05:14:34 AM IST
** Compoler : gcc
** Author : Manoj Kumar Patra, manojpatra.sit@gmail.com
** Organization : SCIS, University of Hyderabad, India.
**
**===============================================================================*/
#include <stdio.h>
int main()
{
printf("\n= = = = = = = = = C Program to print Prime numbers = = = = = =\n");
int n1, n2, i, j, stat;
printf("\nEnter the first number : ");
scanf("%d", &n1);
printf("Enter the second number : ");
scanf("%d", &n2);
printf("\nThe Prime numbers between %d and %d are : \n", n1, n2);
for(i=n1+1; i<n2; ++i)
{
stat=0;
for(j=2; j<=i/2; ++j)
{
if(i%j==0)
{
stat=1;
break;
}
}
if(stat==0)
printf("%d ",i);
}
printf("\n\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n");
}
OutPut:
max@ubuntu:~/cprog$ gcc primePrint.c -o primePrint
max@ubuntu:~/cprog$ ./primePrint
= = = = = = = = = C Program to print Prime numbers = = = = = =
Enter the first number : 2
Enter the second number : 50
The Prime numbers between 2 and 50 are :
3 5 7 11 13 17 19 23 29 31 37 41 43 47
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
**
** File Name : primePrint.c
** Creation Date : Sat 19 Mar 2016 05:08:00 AM IST
** Last Modified : Sat 19 Mar 2016 05:14:34 AM IST
** Compoler : gcc
** Author : Manoj Kumar Patra, manojpatra.sit@gmail.com
** Organization : SCIS, University of Hyderabad, India.
**
**===============================================================================*/
#include <stdio.h>
int main()
{
printf("\n= = = = = = = = = C Program to print Prime numbers = = = = = =\n");
int n1, n2, i, j, stat;
printf("\nEnter the first number : ");
scanf("%d", &n1);
printf("Enter the second number : ");
scanf("%d", &n2);
printf("\nThe Prime numbers between %d and %d are : \n", n1, n2);
for(i=n1+1; i<n2; ++i)
{
stat=0;
for(j=2; j<=i/2; ++j)
{
if(i%j==0)
{
stat=1;
break;
}
}
if(stat==0)
printf("%d ",i);
}
printf("\n\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n");
}
OutPut:
max@ubuntu:~/cprog$ gcc primePrint.c -o primePrint
max@ubuntu:~/cprog$ ./primePrint
= = = = = = = = = C Program to print Prime numbers = = = = = =
Enter the first number : 2
Enter the second number : 50
The Prime numbers between 2 and 50 are :
3 5 7 11 13 17 19 23 29 31 37 41 43 47
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
No comments:
Post a Comment