2:01 PM
c++ Program to calculate G.C.D OF TWO NUMBERS

Write a Program in c++ to calculate G.C.D OF TWO NUMBERS

 
#include<iostream.h> 
#include<conio.h> 
 
void main()
{
int n1,n2;
clrscr();
printf("\nEnter two numbers:");
scanf("%d %d",&n1,&n2);
while(n1!=n2)
{
if(n1>n2)
n1=n1-n2;
else
n2=n2-n1;
}
printf("\nGCD=%d",n1);
getch();
}
 
Note:    
           If you want to change in this program please write through the comment on this page. you can also past similar program of 
             c++ with output.your comment is valuable to the other user and person.
Views: 91 | Added by: vijoriya | Tags: calculate, GCD, program, c++, TWO NUMBERS | Rating: 0.0/0
Total comments: 0
avatar