CrazyEngineers
  • simple C puzzle

    Updated: Oct 26, 2024
    Views: 1.0K
    how will u check the relation of two numbers (greater or lesser or equal to) without using RELATIONAL OPERATORS??????;-);-);-)
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Saandeep Sreerambatla

    MemberOct 8, 2009

    A small idea to find whether greater or smaller.

    if (x/y)
    Printf ("X is greater")
    else
    Printf("y is greater")


    This is a small idea ,i dont know how to check for equal case.

    *thinking*
    Are you sure? This action cannot be undone.
    Cancel
  • yadavundertaker mohit

    MemberOct 8, 2009

    if(x/y==1)
    {
    printf("x=y");
    else
    {
    if(x/y==0)
    printf("y is greater");
    else
    printf("x is greater");
    }
    }
    Are you sure? This action cannot be undone.
    Cancel
  • vignesh1988i

    MemberOct 8, 2009

    HMMMM... 😀 ok.. think think ..... for the second person ok... u have tried .. good.. '==' is is also a relational operator.......😎😎😎
    Are you sure? This action cannot be undone.
    Cancel
  • arun.aj

    MemberOct 9, 2009

    /*a and b declared and defined*/
    if(!(a-b))printf("equal");
    else if(a/b)printf("a is greater");
    else printf("b is greater");

    😉
    Are you sure? This action cannot be undone.
    Cancel
  • Saandeep Sreerambatla

    MemberOct 9, 2009

    arun.aj
    /*a and b declared and defined*/
    if(!(a-b))printf("equal");
    if(a/b)printf("a is greater");
    else printf("b is greater");

    😉

    Good one dude 😀
    Are you sure? This action cannot be undone.
    Cancel
  • yadavundertaker mohit

    MemberOct 9, 2009

    arun.aj
    /*a and b declared and defined*/
    if(!(a-b))printf("equal");
    else if(a/b)printf("a is greater");
    else printf("b is greater");

    😉

    you have IQ like shikamaru...so you are his fan...

    great...
    Are you sure? This action cannot be undone.
    Cancel
  • yadavundertaker mohit

    MemberOct 9, 2009

    vignesh1988i
    HMMMM... 😀 ok.. think think ..... for the second person ok... u have tried .. good.. '==' is is also a relational operator.......😎😎😎

    thanks for telling ....i have a tight hand in C..
    Are you sure? This action cannot be undone.
    Cancel
  • Sahithi Pallavi

    MemberOct 9, 2009

    arun.aj
    /*a and b declared and defined*/
    if(!(a-b))printf("equal");
    else if(a/b)printf("a is greater");
    else printf("b is greater");

    😉

    wonderfull !! Good one..
    Are you sure? This action cannot be undone.
    Cancel
  • arun.aj

    MemberOct 9, 2009

    yadavundertaker
    you have IQ like shikamaru...so you are his fan...

    great...
    lol!! just a fan 😀
    Are you sure? This action cannot be undone.
    Cancel
  • vignesh1988i

    MemberOct 9, 2009

    hmmmm... keep it up... 😀😎 cool,,, so the next constraint for the same problem am gonna give u....

    without using '/' operator how will u do???😲
    Are you sure? This action cannot be undone.
    Cancel
  • arun.aj

    MemberOct 9, 2009

    /*declaring defining a and b... using stdio.h and stdlib.h*/
    /*brute force 😀*/
    if(!(a-b)){printf("equal"); exit(0);}
    while(a && b)
    {
    a--;b--;
    }
    if(a)printf("a is greater");
    else printf("b is greater");

    😀
    Are you sure? This action cannot be undone.
    Cancel
  • vignesh1988i

    MemberOct 9, 2009

    Hmmmm ..... very good man.... good good 😀 😀 so the next constraint , ok by using single if statement how will u do??? in a single 'if' we can finish comparing.... 😎😎
    Are you sure? This action cannot be undone.
    Cancel
  • Sahithi Pallavi

    MemberOct 10, 2009

    arun.aj
    /*declaring defining a and b... using stdio.h and stdlib.h*/
    /*brute force 😀*/
    if(!(a-b)){printf("equal"); exit(0);}
    while(a && b)
    {
    a--;b--;
    }
    if(a)printf("a is greater");
    else printf("b is greater");

    😀
    Awesome man..! Great one..! 😁
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register