C Program to Check Co-Prime Numbers

#include<stdio.h>
#include<conio.h>

int main()
{
	 int num1, num2, hcf, i;
	 clrscr();
	 printf("Enter two numbers:\n");
	 scanf("%d%d", &num1, &num2);
	
	 // Finding HCF
	 for(i=1;i<=num1;i++)
	 {
	  if(num1%i==0 && num2%i==0)
	  {
	   hcf = i;
	  }
	 }
	
	 // Making Decision
	 if(hcf == 1)
	 {
	  printf("%d and %d are CO-PRIME NUMBERS.", num1, num2);
	 }
	 else
	 {
	  printf("%d and %d are NOT CO-PRIME NUMBERS.", num1, num2);
	 }
	 getch();
	 return(0);
}

Output

Run 1:
-------
Enter two numbers:
13 ↲
10 ↲
13 and 10 are CO-PRIME NUMBERS.

Run 2:
-------
Enter two numbers:
15 ↲
10 ↲
15 and 10 are NOT CO-PRIME NUMBERS.

Leave a Reply

Your email address will not be published. Required fields are marked *

https://atozonlinesolutions.com/wp-content/uploads/2017/03/logo_white.png
https://atozonlinesolutions.com/wp-content/uploads/2017/03/logo_white.png
About
Products
Subscribe

If you wish to receive our latest news in your email box, just subscribe to our newsletter. We won’t spam you, we promise!

    Applauz

    As the pioneer of the lean startup movement, APPLAUZ has dedicated it’s time to sharing effective business strategies that help new businesses and enterpreneurs put their money to work in the right way.

    Subscribe

    If you wish to receive our latest news in your email box, just subscribe to our newsletter. We won’t spam you, we promise!

      Applauz

      As the pioneer of the lean startup movement, APPLAUZ has dedicated it’s time to sharing effective business strategies that help new businesses and enterpreneurs put their money to work in the right way.

      Copyright by BOLD THEMES. All rights reserved.