954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

To find which variable is greater

Can anyone tell whats wrong in below code?

I m learning c++ ..so maybe this ll be very easy solution for you guys

Hello i m learning c++ ..so maybe this ll be very easy solution for you guys

#include<iostream.>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
cout<<"Enter Your 1st Value";
cin>>a;
cout<<"Enter Your 2nd value";
cin>>b;
cout<<"Enter your 3rd value";
cin>>c;

              if(a>b&&c)
                {
                    cout<<"1st value is greater";
                }
                           else if(b>a&&c)
                                {
                                          cout<<"2nd value is greater";
                                }
              else if(c>b&&a)
                     {
                           cout<<"3rd value is greater";
                     }

getch();
}
th3learner
Newbie Poster
23 posts since Oct 2009
Reputation Points: 10
Solved Threads: 1
 

replacements:

int main()
{
using namespace std;
int a,b,c;
//Take out clrscr(); from this line, hope this works

bobbytommathew
Newbie Poster
1 post since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

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:

if (a > b && a > c)
   cout << "First value is the max.";
VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
 

@VernonDozier

Thanks for helping me...your code works

@bobbytommathew
thanks for your tips

th3learner
Newbie Poster
23 posts since Oct 2009
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You