Saturday 14 July 2012

Conditional stetment009

Input three numbers, write a program to prove that this three numbers are Pythagorean triples.
N.B. a2 = b2 +c2




#include <stdio.h>
#include <conio.h>
void main ( )
{
        int            a,b,c;
        clrscr ( );
           
        printf ("\n Enter three numbers..:");  scanf ("%d%d%d",&a,&b,&c);
                   
        if ( a * a == b * b + c * c )
        {                             
                        printf ("\n Three numbers are pythagorean tripples.");
        }                              
        else if ( b * b == a * a + c *c )
        {                                        
                        printf ("\n Three numbers are pythagorean tripples.");
        }                                      
        else if ( c * c == b * b + a * a )
        {                                               
                        printf ("\n Three numbers are pythagorean tripples.");
        }                                    
        else                                 
        {                                
                        printf ("\n Three numbers are not pythagorean tripples.");
        }
        getch();
}

1 comment:

Related Posts Plugin for WordPress, Blogger...