WAP to find the GCD(greatest common divisor) of three numbers entered by the user.

#include<stdio.h>
void main()
{
int a,b,c,d,e,f,i;
scanf("%d%d%d",&a,&b,&c);
for(i=a;i>=1;i--)
{
  d=a%i;
  e=b%i;
  f=c%i;
 if((d==0)&&(e==0)&&(f==0))
 {
 printf("the GCD(greatest common divisor) of the numbers is=%d",i);
  break;
 }

 }
}



NOTE-  i have compiled this program in codeblocks if u do it in turbo c++  use  conio.h  header file in the beginning  and getch()  a the  last.

No comments:

Post a Comment

Implemet Stack in python

  class Stack : def __init__ ( self , data ): self . stack = [] if ( data ): self . stack . append ( da...