C programming
Tuesday, 4 October 2011
Program to print GCD of two nos. by method 2
#include<stdio.h>
#include<conio.h>
void main()
{
int n1,n2;
clrscr();
printf("\nEnter two nos. : \n ");
scanf("%d%d",&n1,&n2);
while(n1!=n2)
{
if(n1>=n2-1)
n1=n1-n2;
else
n2=n2-n1;
}
printf("\n GDCD of is : %d ",n1);
getch();
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment