1. Home >
2. Apps >
3. Groups >

# simple C puzzle

Question asked by vignesh1988i in #Brainy Puzzles on Oct 8, 2009
vignesh1988i 路 Oct 8, 2009
Rank D3 - MASTER
how will u check the relation of two numbers (greater or lesser or equal to) without using RELATIONAL OPERATORS??????;-);-);-) Posted in: #Brainy Puzzles
Saandeep Sreerambatla 路 Oct 9, 2009
Rank A2 - PRO
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*
yadavundertaker mohit 路 Oct 9, 2009
Rank B2 - LEADER
if(x/y==1)
{
printf("x=y");
else
{
if(x/y==0)
printf("y is greater");
else
printf("x is greater");
}
}
vignesh1988i 路 Oct 9, 2009
Rank D3 - MASTER
HMMMM... 馃榾 ok.. think think ..... for the second person ok... u have tried .. good.. '==' is is also a relational operator.......馃槑馃槑馃槑
arun.aj 路 Oct 9, 2009
Rank E1 - BEGINNER
/*a and b declared and defined*/
if(!(a-b))printf("equal");
else if(a/b)printf("a is greater");
else printf("b is greater");

Saandeep Sreerambatla 路 Oct 9, 2009
Rank A2 - PRO
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 馃榾
yadavundertaker mohit 路 Oct 9, 2009
Rank B2 - LEADER
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...
yadavundertaker mohit 路 Oct 9, 2009
Rank B2 - LEADER
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..
Sahithi Pallavi 路 Oct 9, 2009
Rank A2 - PRO
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..
arun.aj 路 Oct 9, 2009
Rank E1 - BEGINNER
you have IQ like shikamaru...so you are his fan...

great...
lol!! just a fan 馃榾
vignesh1988i 路 Oct 9, 2009
Rank D3 - MASTER
hmmmm... keep it up... 馃榾馃槑 cool,,, so the next constraint for the same problem am gonna give u....

without using '/' operator how will u do???馃槻
arun.aj 路 Oct 9, 2009
Rank E1 - BEGINNER
/*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");

vignesh1988i 路 Oct 9, 2009
Rank D3 - MASTER
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.... 馃槑馃槑
Sahithi Pallavi 路 Oct 10, 2009
Rank A2 - PRO
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..! 馃榿

## You must log-in or sign-up to reply to this post.

Click to Log-In or Sign-Up