What is the result of a after this for loop run" for( int a=1;a<6;++a){} because first this for loop which type format see | Sololearn: Learn to code for FREE!

+3

What is the result of a after this for loop run" for( int a=1;a<6;++a){} because first this for loop which type format see

that is 1st see int a or a<6 or ++a

2/12/2018 1:57:51 PM

Vibeeshanan Vibee

5 Answers

New Answer

+16

int a; for (a=1; a<6;++a); //or int a; for (a=1; a<6;++a){} /*final value of a will be 6 , bcz after a=6 ... condition'll become false& so loop stops*/

+3

a doesn't exist as it's scope is limited to the loop.

+2

As John said, it a doesn't exist in the outside scope. However, you can do something like this: int a; for (a=1; a<6;++a) ; a will be 6 after the loop.

+1

john wells told correct but i don't ask that matter . i asked the for loop first think it what a<6 or ++a first what do it this for loop

0

for loop will first check the condition i.e., a<6 and after that it will increment the value of a