/* Checking whether no is prime or not */
#include<stdio.h>
#include<conio.h>
void main()
{
int no,i,flag=0;
clrscr();
printf("Enter number : ");
scanf("%d",&no);
if(no==1)
printf("\n 1 is not considered as prime bcoz of the defintn of prime no");
else
{
for(i=2;i<no;i++)
{
if(no%i==0)
{
printf("%d,",i);
flag=1;
}
}
if(flag==0)
printf("\n\n %d is Prime number",no);
else
{
printf(" are the divisers of %d",no);
printf("\n\n %d is Not a prime number",no);
}
}
getch();
}
Output :
#include<stdio.h>
#include<conio.h>
void main()
{
int no,i,flag=0;
clrscr();
printf("Enter number : ");
scanf("%d",&no);
if(no==1)
printf("\n 1 is not considered as prime bcoz of the defintn of prime no");
else
{
for(i=2;i<no;i++)
{
if(no%i==0)
{
printf("%d,",i);
flag=1;
}
}
if(flag==0)
printf("\n\n %d is Prime number",no);
else
{
printf(" are the divisers of %d",no);
printf("\n\n %d is Not a prime number",no);
}
}
getch();
}
Output :
No comments:
Post a Comment