Input three numbers and find the common factors.
#include <stdio.h>
#include <conio.h>
void main ( )
{
int a, b, c, l, co;
clrscr ( );
printf ("\n\t Enter first number...........:"); scanf ("%d", &a);
printf ("\n\t Enter second number..........:"); scanf ("%d", &b);
printf ("\n\t Enter third number...........:"); scanf ("%d", &c);
if ( a < b )
if ( a < c)
l = a;
else
l = c;
else
if ( b < c )
l = b;
else
l = c;
printf ("\n\t The common factors are :-");
for ( co = 1; co <= l; co++ )
{
if ( a % co == 0 && b % co == 0 && c % co == 0 )
printf (" %d", co );
}
getch ( );
}
Click here to contact us
No comments:
Post a Comment