C++ finding common factors of two integers

Gud day, Ive created a simple program that will print out the COMMON FACTORS of two numbers. Hope it helps you alot.

Im using DEV C++ here is the source code:


//This program will produce the common factors of two integers.
#include<stdio.h>
#include<conio.h>
main()
{
int num1,num2,divisor;
printf("Enter a 2 integers: \n");
scanf("%d%d",&num1,&num2);
printf("The common factors of %d",num1);
printf(" and %d",num2);
printf(" is:\n");
(divisor=num1)&&(divisor=num2);
while(divisor>0)
{
if((num1%divisor==0)&&(num2%divisor==0))
printf("\n%d",divisor);
divisor--;
}
getch();
}
Topic archived. No new replies allowed.