wap to find the lcm of three numbers.


#include<stdio.h>
void main()
{

    int num,num2,num3,a=2,lcm=1;
    printf("enter the three numbers\n");
    scanf("%d%d%d",&num,&num2,&num3);
    while((num!=1)||(num2!=1)||(num3!=1))
        if((num%a==0)||(num2%a==0)||(num3%a==0))
        {
        if(num%a==0)num=num/a;
    if(num2%a==0)num2=num2/a;
    if(num3%a==0)num3=num3/a;
    lcm=lcm*a;
        }
        else
            a++;
        printf("\nthe lcm of the three numbers is  %d",lcm);
}


NOTE-  i have compiled this program in codeblocks if u do it in turbo c++  use  conio.h  header file in the beginning  and getch()  a the  last.


here is the proof of the code running..........(click on the image to enlarge)




No comments:

Post a Comment

Implemet Stack in python

  class Stack : def __init__ ( self , data ): self . stack = [] if ( data ): self . stack . append ( da...