C Examples

C Program to Display Prime Numbers Between Two Numbers

A prime number is the number which can be exactly divided by only 1 and the number itself. For example, 5 can only be exactly divided by 1 and the number itself, so 5 is a prime number. But 8 can be divided by 1, 2, 4 and 8 so it is not a prime number but a composite number. To find and display all prime numbers between 10 and 100, nested loop is to be used. The outer loop runs from 10 to 100 and the inner loop checks whether the number is prime or not.

C Program to Check Whether a Number is Prime or Composite

A prime number is the number which can be exactly divided by only 1 and the number itself. For example, 11 can only be exactly divided by 1 and the number itself, so 11 is a prime number. But 14 can be divided by 1, 2, 7 and 14 so it is not a prime number but a composite number.

C program to check whether a number is prime or composite is shown below.

Pages