/* Program: The while loop */
#include <iostream.h>
void main()
{
int num_1 , num_2 ;
cout<<"Enter any two integer values :\n";
cin>>num_1>>num_2 ;
while ((num_1!=0) && (num_2!=0))
{
if (num_1 > num_2)
num_1 = num_1 - num_2 ;
else
num_2 = num_2 - num_1 ;
}
cout<<"The GCD is "<<num_1;
}
#include <iostream.h>
void main()
{
int num_1 , num_2 ;
cout<<"Enter any two integer values :\n";
cin>>num_1>>num_2 ;
while ((num_1!=0) && (num_2!=0))
{
if (num_1 > num_2)
num_1 = num_1 - num_2 ;
else
num_2 = num_2 - num_1 ;
}
cout<<"The GCD is "<<num_1;
}
0 comments:
Post a Comment