Saturday, 8 August 2015

Welcome to C Language World!!!


Hello all, 

You can ask any question related to C lanuage.

You can also ask for programming solution of C.
Program for Pythagorean triple :
For example, 3, 5 and 4 form a Pythagorean triple, since 3*3 + 4*4 = 25 = 5*5
Solution:
#include
int main()
{
          int a,b,c,no,flag=0;
          scanf("%d%d%d",&a,&b,&c);

         if(a>b && a>c)
        {
                    if(b*b+c*c==a*a)
                              flag=1;
                    else
                             flag=0;
         }
        else if(b>a && b>c)
       {
                    if(a*a+c*c==b*b)
                             flag=1;
                    else
                             flag=0;
        }
        else
       {
                      if(a*a+b*b==c*c)
                              flag=1;
                      else
                              flag=0;
        }
        if(flag==1)
                  printf("yes");
        else
                  printf("no");
}

No comments:

Post a Comment