Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int no1,no2,temp,temp1,temp2;
clrscr();
printf("\n enter the two no decesending order ");
scanf("%d%d",&no1,&no2);
temp1=no1;
temp2=no2;
while(no2!=0)
{
temp=no1%no2;
no1=no2;
no2=temp;
}
if(no1==1)
printf("\n the %d and %d is co-prime",temp1,temp2);
else
printf("\n the %d and %d is not co-prime",temp1,temp2);
getch();
}
Output:
What is co-prime ?
The 2 no which has highest common factor as 1 is called co-prime.
#include<stdio.h>
#include<conio.h>
void main()
{
int no1,no2,temp,temp1,temp2;
clrscr();
printf("\n enter the two no decesending order ");
scanf("%d%d",&no1,&no2);
temp1=no1;
temp2=no2;
while(no2!=0)
{
temp=no1%no2;
no1=no2;
no2=temp;
}
if(no1==1)
printf("\n the %d and %d is co-prime",temp1,temp2);
else
printf("\n the %d and %d is not co-prime",temp1,temp2);
getch();
}
Output:
What is co-prime ?
The 2 no which has highest common factor as 1 is called co-prime.
Easiest Program to Find Whether Given Number Is Prime Number Or Not
ReplyDeletevoid main()
Delete{
int i,count=0,n;
clrscr();
scanf("%d",&n);
for(i=1;i<=n;i++)
{
if(n%i==0)
{
count=1;
break;
}
}
if(count==0)
printf("prime");
else
printf("Not prime");
}