# C program to generate and print prime numbers in a given range.

Write a C program to generate and print prime numbers in a given range. Also print the number of prime numbers.
Prime number is a whole number and greater than 1, which is divisible by one or itself.
Example: 2, 3, 5, 7, 11, 13………… Read more about C Programming Language .

`/************************************************************ You can use all the programs on  www.c-program-example.com* for personal and learning purposes. For permissions to use the* programs for commercial purposes,* contact [email protected]* To find more C programs, do visit www.c-program-example.com* and browse!* *                      Happy Coding***********************************************************/ #include <stdio.h>#include <conio.h>#include <stdlib.h>#include <math.h>void main(){ int M, N, i, j, flag, temp, count = 0; clrscr(); printf("Enter the value of M and Nn"); scanf("%d %d", &M,&N); if(N < 2) {  printf("There are no primes upto %dn", N);  exit(0); } printf("Prime numbers aren"); temp = M; if ( M % 2 == 0) {  M++; } for (i=M; i<=N; i=i+2) {  flag = 0;  for (j=2; j<=i/2; j++)  {   if( (i%j) == 0)   {    flag = 1;    break;   }  }  if(flag == 0)  {   printf("%dn",i);   count++;  } } printf("Number of primes between %d  and %d = %dn",temp,N,count);}`
`Read more Similar C ProgramsLearn C ProgrammingNumber System`

You can easily select the code by double clicking on the code area above.

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

(you can send this program to your friend using this button)

To browse more C Programs visit this link
(c) www.c-program-example.com

# C Program to check whether the given number is prime or not. Print the suitable messages.

C Program to check whether the given number is prime or not and Print the suitable messages. Prime number is a whole number and greater than 1, which is divisible by one or itself.
Example: 2, 3, 5, 7, 11, 13………… Read more about C Programming Language .

`Read more Similar C ProgramsLearn C ProgrammingNumber System`

You can easily select the code by double clicking on the code area above.