Monday 8 October 2012

Loop control structure071

Write a program to determine G.C.D. of two input number. 

#include <stdio.h>
#include <conio.h>
void main ( )
{                              
        int         n1, n2, d;
        clrscr ( );
                                      
        printf("\n\n\n\t\t Enter a number..:");    scanf("%d",&n1);
        printf("\n\n\t\t Enter a number..:");    scanf("%d",&n2);
                             
        while ( n2 != 0 )
        {                               
                       d = n1 % n2;
                       n1 = n2;
                       n2 = d;
        }
              
        printf("\n\n\n\t\t G.C.D = %d",n1);
        getch();
}
Click here to contact us 

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...