944,028 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 431
  • C++ RSS
Oct 10th, 2009
0

To find which variable is greater

Expand Post »
Can anyone tell whats wrong in below code?

I m learning c++ ..so maybe this ll be very easy solution for you guys
C++ Syntax (Toggle Plain Text)
  1. Hello i m learning c++ ..so maybe this ll be very easy solution for you guys
  2.  
  3. #include<iostream.>
  4. #include<conio.h>
  5. void main()
  6. {
  7. int a,b,c;
  8. clrscr();
  9. cout<<"Enter Your 1st Value";
  10. cin>>a;
  11. cout<<"Enter Your 2nd value";
  12. cin>>b;
  13. cout<<"Enter your 3rd value";
  14. cin>>c;
  15.  
  16. if(a>b&&c)
  17. {
  18. cout<<"1st value is greater";
  19. }
  20. else if(b>a&&c)
  21. {
  22. cout<<"2nd value is greater";
  23. }
  24. else if(c>b&&a)
  25. {
  26. cout<<"3rd value is greater";
  27. }
  28.  
  29. getch();
  30. }
Last edited by th3learner; Oct 10th, 2009 at 1:25 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
th3learner is offline Offline
23 posts
since Oct 2009
Oct 10th, 2009
0
Re: To find which variable is greater
replacements:

int main()
{
using namespace std;
int a,b,c;
//Take out clrscr(); from this line, hope this works
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bobbytommathew is offline Offline
1 posts
since Oct 2009
Oct 10th, 2009
1
Re: To find which variable is greater
This isn't a code snippet. If possible, please change the thread type to a regular old thread as opposed to a code snippet.

The && operator doesn't work that way. You want something like this:

C++ Syntax (Toggle Plain Text)
  1. if (a > b && a > c)
  2. cout << "First value is the max.";
Featured Poster
Reputation Points: 2614
Solved Threads: 687
Posting Expert
VernonDozier is offline Offline
5,375 posts
since Jan 2008
Oct 10th, 2009
0
Re: To find which variable is greater
@VernonDozier

Thanks for helping me...your code works

@bobbytommathew
thanks for your tips
Reputation Points: 10
Solved Threads: 1
Newbie Poster
th3learner is offline Offline
23 posts
since Oct 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: whats wrong with my program??help needed for C++ qn
Next Thread in C++ Forum Timeline: C++ maskedtextbox (IP address)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC