Search:
Forum
Beginners
Help! How to compare three integers usin
Help! How to compare three integers using c++
Oct 3, 2016 at 2:59pm UTC
ll1234
(7)
Write your question here.
cin a,b,c,then cout the maximum integer. For example,cin 1,4,8,cout 8.
Oct 3, 2016 at 3:28pm UTC
keskiverto
(10402)
You can't. The binary operators take only two operands.
However, you can do more than one comparison before you have to show the result.
Lets do this: First you will write a program that reads three integers and then you show it to us.
Oct 3, 2016 at 6:18pm UTC
kamal choudhary
(8)
Yes as keskiverto said that you can't compare two numbers at the same time. Instead you will have to compare numbers one comarison at one time. A simple way to do that is nestes if condition.For example
If(a>b)
{ if(a>c)
{ cout<<"maximum="<<a;}
}
Last edited on
Oct 3, 2016 at 6:19pm UTC
Oct 3, 2016 at 7:44pm UTC
Handy Andy
(5051)
Hello ll1234,
See message
http://www.cplusplus.com/forum/beginner/198974/
for some ideas.
Andy
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs