Write a C program for HCF of Two Numbers.

 

TASK-

Write a C program for HCF of Two Numbers.

HCF= The highest common factors of each member of group   

CODE:

#include<stdio.h>
int main()
{
int h,i,l=1,x,y;

//Asking number for HCF

 printf("Enter two numbers: ");

 printf("\n1- ");
 scanf("%d",&x);
 printf("\n2- ");
 scanf("%d",&y);


for (i=1;i<=(x*y);i++)
{
if (x%i==0&&y%i==0)
l=i;
}
printf("Hcf of %d and %d is %d",x,y,l);
getchar();
return 0;
}

EXPECTED OUTPUT:




NEED WORK PRODUCE WORK

My name is Abdul Rehman I am from Pakistan. I am doing BS in Computer and information sciences. Currently, I am creating these blogs to help students of computer sciences all over the world..

Post a Comment (0)
Previous Post Next Post