Recent Posts

9-latest-250px-course

Write a C program to find the GCD or HCF of two numbers

Write a C program to find the GCD or HCF of two numbers


Program:-     

#include<stdio.h>

#include<stdlib.h>

int main()

{

int a,b,gcd;

printf(“\nEnter two numbers : “);

scanf(“%d %d”,&a,&b);

int i;

for(i = 1; i <= a && i <= b; i++)

{

if((a % i == 0) && (b % i == 0))

{

gcd = i;

}

}
printf(“\nGCD of %d and %d is %d “,a,b,gcd);

printf(“\n”);

return 0;

}

Output:-

....
SHARE

Milan Tomic

Hi. I’m Designer of Blog Magic. I’m CEO/Founder of ThemeXpose. I’m Creative Art Director, Web Designer, UI/UX Designer, Interaction Designer, Industrial Designer, Web Developer, Business Enthusiast, StartUp Enthusiast, Speaker, Writer and Photographer. Inspired to make things looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment