Triplet of three numbers (a,b,c) 1, if a>b>c 0, otherwise

–2 votes
asked Aug 9 by anonymous
Input : Triplet of three numbers (a,b,c)
Output : 1 if a>b>c
              0, otherwise

2 Answers

+1 vote
answered Aug 12 by anonymous
edited Aug 15
#include<stdio.h>

int main(){

int a,b,c;

printf("Enter 3 numbers:\n");

scanf("%d %d %d",&a, &b, &c);

if(a>b && b>c){
    printf("1");
}
else{
    printf("0");
}

return 0;

}
commented Aug 13 by (100 points)
This answer is causing compile error.
because comparison operator can compare two numbers only.
like this:
a < b < c           (x)
a < b && b < c (o)
–2 votes
answered Aug 13 by (100 points)
#include <cstdio>

int main() {

    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);

    printf("%d", (a < b && b < c) ? 1 : 0);

    return 0;

}
commented Aug 14 by anonymous
its stdio.h for header file
and its a>b&&b>c
commented Aug 16 by codenstory
I'm sorry.
but in C++, cstdio should be used instead of stdio.h.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...