GCD
#include <iostream.h> #include <conio.h> void main() { clrscr(); int f,s,gcd; cout<<"enter first and second number:"; cin>>f>>s; for(int i=1;i<=f && i<=s;i++) { if(f%i==0 && s%i==0) { gcd=i; } } cout<<"gcd is:"<<gcd; getch(); }
output
(Visited 155 times, 1 visits today)