fork(1) download
  1. #include<stdio.h>
  2. int main() {
  3. int n,i,gcd;
  4. printf("Enter how many no.s u want to find gcd : ");
  5. scanf("%d",&n);
  6. int arr[n];
  7. printf("\nEnter your numbers below :- \n ");
  8. for(i=0;i<n;i++) {
  9. scanf("%d",&arr[i]);
  10. }
  11. gcd=arr[0];
  12. int j=1;
  13. while(j<n) {
  14. if(arr[j]%gcd==0) j++;
  15. else {
  16. gcd=arr[j]%gcd;
  17. i++;
  18. }
  19. }
  20. printf("\nGCD of k no.s = %d ",gcd);
  21. return 0;
  22. }
Success #stdin #stdout 0s 9424KB
stdin
4
24 16 8 4
stdout
Enter how many no.s u want to find gcd : 
Enter your numbers below :- 
 
GCD of k no.s = 4