#include<stdio.h>
int main()
{
int i, n, count = 0;
printf("Enter any Positive integer number to check Prime or Not\n");
scanf("%d",&n);
for(i = 1; i <= n; i++)
{
if(n % i = = 0)
{
count = count + 1;
}
}
if(count = = 2)
{
printf("The given %d number is Prime",n);
}
else
{
printf("The given %d number is Not Prime",n);
}
return 0;
}
INPUT 1:
Enter any Positive integer number to check Prime or Not
5
OUTPUT 1:
The given 5 number is Prime
INPUT 2:
Enter any Positive integer number to check Prime or Not
12
OUTPUT 2:
The given 16 number is Not Prime
Monday, December 17, 2018
WAP in C to check whether a given number is Prime or Not
Topics
# C Programming
# Simple Programs
About HindiKisseKahaniyaan
Easy Programming All is a free blogger to the students who wants to learn programming in C, HTML, CSS, Bootstrap, Web Designing from home. The students can learn programming free of cost at their home. We provide best logics about any program. If you want to ask any logic of any program you can comment to us in comment box.
Simple Programs
Labels:
C Programming,
Simple Programs
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment