#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    Triad number in c


    write a program to print triad numbers. any three numbers will be triad numbers if they satisfy the following conditions.
    1) each number is a three number.
    2) all the digits in the three numbers(total 9 digits) should be different.
    plz..explain third point what say...i am not understanding these point..they are...
    3)second number should be twice the first number and third number should be thrice the first number.

    *******************
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    int m,n,p,num;
    int i,k,d1,d2,d3;
    for(num=100;num<=999/3;num++)/*loop a*/
    {
    for(i=num;i<=3*num;i+=num)/*loop b*/
    {
    k=i;
    d1=k%10; k/=10;
    d2=k%10; k/=10;
    d3=k%10; k/=10;
    if(d1==d2||d2==d3||d3==d1)
    goto nextnum;
    }/*end of loop b*/
    for(m=num;m>0;m/=10)/*loop c*/
    {
    d1=m%10;
    for(n=num*2;n>0;n/=10)/*loop d*/
    {
    d2=n%10;
    for(p=num*3;p>0;p/=10)/*loop e*/
    {
    d3=p%10;
    if(d1==d2||d2==d3||d3==d1)
    goto nextnum;
    }/*end of loop e*/
    }/*end of loop d*/
    }/*end of loop c*/
    printf("%d %d %d\n",num, num*2, num*3);
    nextnum:
    }/*end of loop a*/
    getch();
    }/*end of main()*/
    output:
    219 438 657
    267 534 801
    plz explain this program code and execution triad numbers? what is triad number?
    3)second number should be twice the first number and third number should be thrice the first number.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Location
    India
    Posts
    95
    Rep Power
    4
    second number = 2 * first number and third number = 3 * first number

    from your explaination a set of three 3 digit number which has 9 different digit,and follow above condition are triad numbers

IMN logo majestic logo threadwatch logo seochat tools logo