Am I on the right track?

In this program:
#include <iostream>
#include <cmath>
using namespace std;

int main()
{int a = 750;
if (a > 0)
if (a>=1000)
a=0;
else
a *= 2;
else
a *=10;

return (0) ;
}
would the memory snapshot be a=0?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream> 
#include <cmath> 
using namespace std;

int main()
{int a = 750;
if (a > 0)
if (a>=1000)
a=0;
else
a *= 2;
else
a *=10;

cout << a;
return (0) ;
}


Add a cout << a and find out.
Thank you kind sir.
Hey, your program doesn't make much sense.

Like, the two if's basically are &&. Like, if a is greater than 0 and if a is greater than 1000 or equals to 1000.

With it like this, then EVERY POSITIVE WHOLE NUMBER including 0 would turn the value a to 0.

I mean it does make sense but I don't think you intend it that way?

I think you may of intended t make it Between 0 and up to 1000. I don't know. But yeah, just in case; was to let u know.
closed account (zb0S216C)
AARON HENDERSON wrote:
Thank you kind sir. (sic)

Blessing of Akatosh upon ye.

Wazzak
Topic archived. No new replies allowed.