both these increments operator are same because of the following reasons
1.i++ is postincrement operator means it increments the next value of i after
printing that value
for example
(for int i=0;i<10;i++)
{
cout<<i<<endl;
}
after printing zero it will make increment
whereas
(for int j=0;j<10;++j)
{
cout<<j<<endl;
}
it will make increment first then print values of j in the given range
regards
bilal nawaz
________________________________
From: Asad Abbas <[email protected]>
To: c prog <[email protected]>; c4swimmers ygroup
<[email protected]>
Sent: Sun, October 18, 2009 4:26:12 PM
Subject: [c-prog] for loop i++ and ++i ?
Why these both statements have same output??
why i++ and ++i works alike in for loop??
for(int i=0;i<5;i++)
or
for(int i=0;i<5;++i) ;
cout << i << endl;
//output:
/*
0
1
2
3
4
*/
Thanx in Advance
Asad Abbas
UET Taxila
Pakistan---- --------- --------- --------- --------- --------- ---------
One of the main causes of the fall of the Roman Empire was that, lacking zero,
they had no way to indicate successful termination of their C programs.
Robert Firth
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]