Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
To find prime numbers through C language
1. C PROGRAMME TO IDENTIFY
WHETHER A NUMBER IS PRIME OR
COMPOSITE
BY-SAURABH KHETAN
2. The prime numbers are those numbers
which are divisible by themselves and
unity.
We will implement this theory while
constructing a program to find whether a
number is prime or composite in C
language.
The main logic behind finding whether a
number is prime number or not, we need
to keep on dividing the number with
number occurring before it.
The program can be written as follows:-
3. #include<stdio.h>
int main()
{
int num, i=2;
printf(“enter a number”);
scanf(“%d”,&num);
while(i<=num-1)
{
if(num%i==0)
{
printf(“the entered number is
composite”);
break;
}
else
i++;
}
4. if(i==num)
{
printf(“the entered number is a
prime number”);
}
}
5. The following program can be made to
run in any of the compilers.
For example:- Turbo c, Microsoft visual
studio.
Only for the compilers supported by
windows operating system.
This is a simplest program to identify
whether a number is prime or composite.
The user just have to enter the desired
number and the result is displayed.
Can be used to make school children
comfortable with concept of the prime
numbers.
6. For any more details about this program
you can enquire by sending me an e-mail.
saurabh.khetan53@gmail.com
Any query regarding it will be solved as
soon as possible.
Do mention your problem in detail while
sending me an e-mail.