by Dinesh Thakur Category: C Programming (Pratical)

 

#include<stdio.h>

void main()
{
    int i,j,h,n,a[100];
    int hcf(int,int);
    clrscr();
    printf("Enter how many numbers :");
    scanf("%d",& n);
    for(i=0;i<n;i++)
        {
            printf("Enter a Number :");
            scanf("%d",& a[i]);
        }
            for(i=0;i<n-1;i++)
                {
                     h=hcf(a[i],a[i+1]);
                     a[i+1]=h;
                }
                     printf("The HCF is :  %d",h);
                     getch();
  }
       int hcf(int a,int b)
         {
              if(a%b==0)
               {
                      return b;
               }
              else
              {
                      return(hcf(b,a%b));
              }
         } 

Print HCF of N Numbers

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content