Programming with Passion

Make the best out of everything.

Monday, 12 January 2015

Here Is A new program for all the visitors..

Here Is A new program for all the visitors..

This is a program for finding if two nos. are co-prime or not . It work for T cases. First of all enter no. of cases and then two nos. space separated in each line to find whether they co- prime or not.
#include<iostream.h>
void main()
{
int a,  b,  T ,  c=0,  i;
cin>>T;
while(T--)
{
cin>>a>>b;
for(i=2;i<=a;++i)
if(a%i==0  &&  b%i==0)
++c;
if(c)
{
cout<<"Not a Co- Prime \n";
c=0;
}
else
cout<<"Co-Prime \n";
}
}

Enjoy.. 

No comments:

Post a Comment