>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.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
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!
Ene Uran
Posting Virtuoso
1,723 posts since Aug 2005
Reputation Points: 625
Solved Threads: 213
bumsfeld
Nearly a Posting Virtuoso
1,445 posts since Jul 2005
Reputation Points: 404
Solved Threads: 184
>i am just trying to solve some c - puzzles
Then why are you asking us what the answers are?
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
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.
Rashakil Fol
Super Senior Demiposter
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
>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.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401