Re: A83: OT:C++ program


[Prev][Next][Index][Thread]

Re: A83: OT:C++ program




cnt = cnt++? lol.. =)
Either use basic style: cnt = cnt + 1
or use lazy c style: cnt++
but don't combine them. What you're doing is that you're reading off the value
of cnt (say it's 1), then incrementing it. But then you place the 1 into cnt
again. If you'd done cnt = ++cnt it would've worked, but it still wouldn't be
necessary.
So, as I said, for(int cnt=1; cnt<=10; cnt++) would do it.

Linus

On 14-Sep-98, ManjiLump@aol.com wrote:

>What's wrong with this code, every time I run the prgm it displays 1
>constantly. When it should display each of the values (1-10) held by the var
>cnt. Can someone please help me out, so I don't have to constantly restart my
>computer everytime it loops 1 and freezes up.
>Michael

>#include<iostream.h>
>#include<stdio.h>
>#include<ctype.h>
>#include<conio.h>
>void main()
>{
>clrscr();
>for(int cnt=1;cnt<=10;cnt=cnt++)
>cout<<cnt<<endl;
>}



References: