Welcome to the World of Online Learning:
Hello Friends “This blog helps you to learn C programming concepts. You can learn C language at your own speed and time. One can learn concepts of C language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Write a C program to Prime Number
PROGRAM: Prime Number
/* Prime Number using while loop */
#include<stdio.h>
int main()
{
int a,i,f;
printf("Enter a number: ");
scanf("%d",&a);
f=0;
i=2;
while(i <= a/2)
{
if(a%i == 0)
{
f=1;
break;
}
i++;
}
if(f==0)
printf("Prime Number")
else
printf("Not Prime Number");
return 0;
}
-------------------------------------------------------
/* Prime number using for loop */
#include<stdio.h>
int main()
{
int a,i,f;
printf("Enter a number: ");
scanf("%d",&a);
f=0;
for(i=2;i <= a/2;i++)
{
if(a%i == 0)
{
f=1;
break;
}
}
if(f==0)
printf("Prime Number")
else
printf("Not Prime Number");
return 0;
}