I have two integer numbers. I want to find which number is greater than other one without using relational operators.
kvprajapati
1,826
Posting Genius
Team Colleague
Recommended Answers
Jump to PostYou could use sprintf to convert int numbers to string then compare them with strcmp or memcmp
Jump to PostIt is often prudent to test around the edges.
#include <stdio.h> #include <stdlib.h> #include <limits.h> int cmp1(int a, int b) { return a == b ? 0 : a < b ? -1 : 1; } int cmp2(int x, int y) { if ( x - y …
All 5 Replies
VatooVatoo
21
Light Poster
ArkM
1,090
Postaholic
neigyl_noval
2
Light Poster
Luckychap
68
Posting Pro in Training
Dave Sinkula
2,398
long time no c
Team Colleague
Salem
commented:
Yes indeed
+31
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.