cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Qns: (x<y) ? y * 2: y * 3
Qns: (x<y) ? y * 2: y * 3
Sep 6, 2009 at 5:15am UTC
makan007
(77)
#include <iostream>
using namespace std;
int main ()
{
int x = 1, y = -2;
x -= (x<y) ? y*2 : y*3;
cout << "x = " << x << ", y = " << y << endl;
return 0;
}
Can someone guide me what is the program asking? The result are x = 7, y = -2 after compiled.
Sep 6, 2009 at 5:34am UTC
InLight
(47)
(x<y) ? y * 2: y * 3
Is the same as:
1
2
3
4
if
( x < y ) x -= y*2;
else
x -= y*3;
Sep 6, 2009 at 6:13am UTC
makan007
(77)
Thank you so much. :)
Topic archived. No new replies allowed.