Embed
Email

greatest common factor

Document Sample

Description

c/c programme

Shared by: Sumit Trivedi
Categories
Tags
Stats
views:
2
posted:
1/8/2012
language:
pages:
1
// Program to find the greatest common factor

#include

#include

void main()

{

int gcm(int,int);

int num1,num2,gcf,choice;

clrscr();

do

{

printf(" Enter two numbers -->");

scanf(" %d %d",&num1,&num2);

gcf=gcm(num1,num2);

printf(" The greatest common factor of ");

printf("%d and %d is --> %d",num1,num2,gcf);

printf(" \n Wish to continue.........");

printf("\n \t 1.) To continue \n \t \t 2.) Exit \n");

scanf("%d",&choice);

}

while(choice==1);

getch();

}



int gcm(int a ,int b)

{

int p,h;

p=a*b;

for(int i=1;i<=p;i++)

{

if(a%i==0&&b%i==0)

h=i;

}

return (h);

}



Other docs by Sumit Trivedi
Reading _ Writing array
Views: 6  |  Downloads: 0
project report format
Views: 5  |  Downloads: 0
Matrix Multiplication
Views: 2  |  Downloads: 0
Transpose Matrix
Views: 9  |  Downloads: 0
c programmes
Views: 6  |  Downloads: 0
c programmes
Views: 6  |  Downloads: 0
bank questions
Views: 10  |  Downloads: 0
sports facts
Views: 5  |  Downloads: 0
c programmes
Views: 5  |  Downloads: 0
CLOUD COMPUTING,QUANTAM COMPUTING
Views: 15  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!