logo codesdope

I am tryng to run for loop in codeblocks with the shown code.Though I haven't initialized the variable a, helloworld is getting printed 8 times.why so



     int main ()


int a;


       printf("helloworld ");
     return 0;



  •    pongo

    If the memory values are not defined by the user at the start of the code’s execution in C, the CPU will set the variable value to anything that is acceptable in computer programming language, this is usually termed as garbage value.

    • Also if I m initiating with a negative value say -1 it is printing only 10 times instead of 11.Why?
      - mahi6683
    • And thankks for ur help.
      - mahi6683
    • if u initiatize a=-1 then value of a in every loop get incremented every time by 1 n whileloop will run till a=9 i.e 11 times.
      - pongo

Write your answer

Welcome.please sign up.


Welcome.please login.