0

So the question is following:

Given three integers as input determine if the values were entered in ascending order (from smallest to largest) and whether those values represent a Pythagorean Triplet.Click Here

**Examples**

*Enter the three values to test (a b c): 3 4 5

a < b < c Status: 1

Pythagorean Triplet Status: 1

Enter the three values to test (a b c): 4 3 5

a < b < c Status: 0

Pythagorean Triplet Status: 0

Enter the three values to test (a b c): 3 5 6

a < b < c Status: 1

Pythagorean Triplet Status: 0*

Here is my attempt on the question:

```
/*
* Description: Program is aimed towards to take three inputs from user.
* We have to check that the numbers are in ascending order.
* We are not allowed to use any conditional statement only, basic math
* operations like (/,%,+,-,etc), but no logical operators or ternary operator,etc.
* If the numbers are in ascending order then output is 1, or else 0.
* If the number is in ascending order, then we check if it is pythogorean triplet and if it
* then output is 1 or else 0.
* Condition: If the number are not ascending order, then by default its pythogorean triplet answer
* should also be 0.
*/
#include <stdio.h>
#include <math.h>
int main()
{
int a,b,c,x,sum,e,f,y;
/*
* a = number 1
* b = number 2
* c = number 3
* e = holds the value obtained after modding a,b
* f = holds the value obtained after modding c,b
* y = holds the value obtained after modding e,f
*/
printf("Enter the numbers:");
scanf("%d %d %d",&a,&b,&c);
sum = ((a*a)+(b*b));
e = a%b;
f = c%b;
y = e%f;
x = sum/(c*c);
printf("Value is to check a<b<c: %d\n",x);
printf("Value is to check it is Pythogorean Triplet: %d\n",y);
//printf("Value is: %d\n",(36/34));
return 0;
}
```

Code was working fine but gave wrong outputs when I tested with cases like following:

4 3 5

4 5 3

*Edited 2 Years Ago by aka619ASH*