Can we find the smallest of three integers, without using any of the comparison operators....logic please

Recommended Answers

All 13 Replies

int a=rand();
int b=rand();
int c=rand();
std::vector<int> vec;
vec.push_back(a);
vec.push_back(b);
vec.push_back(c);
std::cout<< *std::min_element(vec.begin(),vec.end())<<std::endl;

not a comparison operator in sight

>Can we find the smallest of three integers, without using any of the comparison operators....logic please
Can we find out why you're interested in such a silly problem? Logic please.

int a=rand();
int b=rand();
int c=rand();
std::vector<int> vec;
vec.push_back(a);
vec.push_back(b);
vec.push_back(c);
std::cout<< *std::min_element(vec.begin(),vec.end())<<std::endl;

not a comparison operator in sight

However, there is a comparison operator out of sight!

Silly logic indeed.

>Can we find the smallest of three integers, without using any of the comparison operators....logic please
Can we find out why you're interested in such a silly problem? Logic please.

silly logic indeed

Hey cmon guys...i don't have a leg-pull function as friend.....i am just trying to solve some c - puzzles

>i am just trying to solve some c - puzzles
Then why are you asking us what the answers are?

It's funny, but almost all of sunnypalsingh's questions sound like questions that an idiot teacher would ask. Knowing the answer to such questions doesn't help anyone understand programming and definately doesn't help a programmer develop good technique.

Then why are you asking us what the answers are?

bcoz i was not able to do it

and don't reply if u don't want to..plz

It's funny, but almost all of sunnypalsingh's questions sound like questions that an idiot teacher would ask. Knowing the answer to such questions doesn't help anyone understand programming and definately doesn't help a programmer develop good technique.

Actually, I have had this sort of question, and it was appropriate for the class I was taking. It doesn't help anyone understand programming, but it helps some understand how integers are represented, or why they are represented the way that they are.

bcoz i was not able to do it

Really? How long did you try? If you tried again for the same length of time, would you necessarily not be able to solve the problem then? If you can't be creative enough and effortful enough to solve this problem, how will you ever be creative enough to come up with solutions to harder problems?

The benefit of this problem is that in solving it, you'll improve your creativity. Yes, creativity is learned. Well, conditioned, maybe. At least the problem-solving kind of creativity is. Anyway, this skill is important to your ability in the arena of computer programming, and you might as well get good at it now, or else you'll suck forever.

>and don't reply if u don't want to..plz
I do want to reply, otherwise I wouldn't be here. However, I don't want to feed you answers to problems that you obviously haven't worked very hard to solve. If you want better help, show us what you've tried, how it didn't work, and what you learned from the process instead of just asking for the answer.

>
I do want to reply, otherwise I wouldn't be here. However, I don't want to feed you answers to problems that you obviously haven't worked very hard to solve. If you want better help, show us what you've tried, how it didn't work, and what you learned from the process instead of just asking for the answer.

Ok..i'll keep that in mind next time

Is it actually possible? Because everything is relative so to find minimum or maximum we got to compare it with other and for that comparison operators have to show up? :confused:

Is it actually possible? Because everything is relative so to find minimum or maximum we got to compare it with other and for that comparison operators have to show up? :confused:

There must be some way the comparison operators have been implemented

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.