Skip to main content
added 2 characters in body
Source Link
Const
  • 1.4k
  • 1
  • 14
  • 29

I need to do if the i variable is greater than 10 then check the g condition and if it is equal to 1 complete the loop...

Your usage to Conditional operator there is wrong.

Instead, you should be simply using logical && operator there

for (int i = 0, g = 12; /*first condition*/ && /* second condition */ ; i++, g--) // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

Therefore, you need:

for (int i = 0, g = 12; i < 10 && g >= 1 ; i++, g--) // ^^^^^^^^^^^^^^^^ 

The above loop will first check whether the ii is less than 10, if true will check the next condition which is g is grater than or equal to 1: if that is also true: do the iteration!

I need to do if the i variable is greater than 10 then check the g condition and if it is equal to 1 complete the loop...

Your usage to Conditional operator there is wrong.

Instead, you should be simply using logical && operator there

for (int i = 0, g = 12; /*first condition*/ && /* second condition */ ; i++, g--) // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

Therefore, you need:

for (int i = 0, g = 12; i < 10 && g >= 1 ; i++, g--) // ^^^^^^^^^^^^^^^^ 

The above loop will first check whether the i is less than 10, if true will check the next condition which is g is grater than or equal to 1: if that is also true: do the iteration!

I need to do if the i variable is greater than 10 then check the g condition and if it is equal to 1 complete the loop...

Your usage to Conditional operator there is wrong.

Instead, you should be simply using logical && operator there

for (int i = 0, g = 12; /*first condition*/ && /* second condition */ ; i++, g--) // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

Therefore, you need:

for (int i = 0, g = 12; i < 10 && g >= 1 ; i++, g--) // ^^^^^^^^^^^^^^^^ 

The above loop will first check whether the i is less than 10, if true will check the next condition which is g is grater than or equal to 1: if that is also true: do the iteration!

added 270 characters in body
Source Link
Const
  • 1.4k
  • 1
  • 14
  • 29

I need to do if the i variable is greater than 10 then check the g condition and if it is equal to 1 complete the loop...

You needYour usage to Conditional operator there is wrong.

Instead, you should be simply using logical && operator there

for (int i = 0, g = 12; /*first condition*/ && /* second condition */ ; i++, g--) // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

Therefore, you need:

for (int i = 0, g = 12; i < 10 && g ==>= 1 ; i++, g--) // ^^^^^^^^^^^^^^^^ 

The above loop will first check whether the i is less than 10, if true will check the next condition which is g is grater than or equal to 1: if that is also true: do the iteration!

I need to do if the i variable is greater than 10 then check the g condition and if it is equal to 1 complete the loop...

You need simply logical && operator there

for (int i = 0, g = 12; /*first condition*/ && /* second condition */ ; i++, g--) // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

Therefore, you need:

for (int i = 0, g = 12; i < 10 && g == 1 ; i++, g--) // ^^^^^^^^^^^^^^^^ 

I need to do if the i variable is greater than 10 then check the g condition and if it is equal to 1 complete the loop...

Your usage to Conditional operator there is wrong.

Instead, you should be simply using logical && operator there

for (int i = 0, g = 12; /*first condition*/ && /* second condition */ ; i++, g--) // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

Therefore, you need:

for (int i = 0, g = 12; i < 10 && g >= 1 ; i++, g--) // ^^^^^^^^^^^^^^^^ 

The above loop will first check whether the i is less than 10, if true will check the next condition which is g is grater than or equal to 1: if that is also true: do the iteration!

added 270 characters in body
Source Link
Const
  • 1.4k
  • 1
  • 14
  • 29

I need to do if the i variable is greater than 10 then check the g condition and if it is equal to 1 complete the loop...

You need simply logical &&logical && operator there

for (int i = 0, g = 12; /*first condition*/ && /* second condition */ ; i++, g--) // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

Therefore, you need:

for (int i = 0, g = 12; i < 10 && g == 1 ; i++, g--) // ^^^^^^^^^^^^^^^^ 

You need simply logical && there

for (int i = 0, g = 12; i < 10 && g == 1 ; i++, g--) 

I need to do if the i variable is greater than 10 then check the g condition and if it is equal to 1 complete the loop...

You need simply logical && operator there

for (int i = 0, g = 12; /*first condition*/ && /* second condition */ ; i++, g--) // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

Therefore, you need:

for (int i = 0, g = 12; i < 10 && g == 1 ; i++, g--) // ^^^^^^^^^^^^^^^^ 
Source Link
Const
  • 1.4k
  • 1
  • 14
  • 29
Loading