This is assignment:
i = 1
This is comparison:
i == 1
[edit]And these are code tags : [code][/code]
;)
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
what does " if (i=0) " do?
think about that, there's an error on that line
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
Well, I think it should go to cout << The number you entered is zero. Right??
Is zero true or false?
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
you're not thinking!
What does i=0 do?
So what happens when you do if (i=0) ?
And indeed what is the result if if (i=0) ?
some hints:
assignment, false
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
Okay, that's not really your code is it? Your compiler must be screaming at you. Are you having trouble with the error messages?
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
>declare global int variable within main named x initialized to 0
int x = 0;
declare a local int variable in main named y
int main()
{
int y;
return 0;
}
>prompt user for value of y in main
You did a prompt in your first post. It was the cout/cin combo.
>add loop that calls function incx y number of times
You'll need a function incx() prototyped or defined before you call it. The function definition will look a lot like main. You'll likely want to use a for loop from 0 to y.
for ( int i = 0; i < y; ++i )
{
/* loop body */
}
>include function incx to increment value of x by one
Something to put in the loop body.
>and print the value of x after each loop
Something to put in the loop body.
That ought to be enough for you to take another spin at it. And please post your next code attempt within code tags : [code][/code].
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314