Changed a = a + 1 to a++ (#28742)
Changed a = a + 1 to a++ in implementation section. It is best practice to use a++ rather than a = a + 1
This commit is contained in:
committed by
Christopher McCormack
parent
b8b1e029db
commit
b4044fe267
@@ -66,8 +66,7 @@ using std::endl;
|
|||||||
|
|
||||||
int main () {
|
int main () {
|
||||||
// for loop execution
|
// for loop execution
|
||||||
for( int a = 10; a < 20; a = a + 1 )
|
for( int a = 10; a < 20; a++ ) { // The loop will run till the value of a is less than 20
|
||||||
{ // The loop will run till the value of a is less than 20
|
|
||||||
cout << "value of a: " << a << endl;
|
cout << "value of a: " << a << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +98,7 @@ The body of the for loop need not be enclosed in braces if the loop iterates ove
|
|||||||
|
|
||||||
int main () {
|
int main () {
|
||||||
// Single line for loop
|
// Single line for loop
|
||||||
for( int a = 10; a < 20; a = a + 1 )
|
for( int a = 10; a < 20; a++ )
|
||||||
cout << "value of a: " << a << endl;
|
cout << "value of a: " << a << endl;
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user