![]() |
some observations need explanation
Hello friends,
I am a newbie, Just did some simple experiments but found some weird observations. Lets see this code Code:
main()Yes I have not initialized the variable 'i' This code gives output 0 lets see this code Code:
main()Why this the output 813, when the initial value in variable i is 0; and have a look at this code Code:
main()Code:
main()Even using the function clrscr() give different results. Can anuone explain these observations, Thanks a lot |
Re: some observations need explanation
Sure. But since you know that i is uninitialized and you're farbling with it anyway, you won't be satisfied. Your code results in what the standard describes as undefined behavior.
Your time would be much better invested in learning the language properly. If that's boring, at the moment, perhaps you should READ the standard. Now, if you'll excuse me, I'm going to go bombard various parts of my body with random levels of radiation. Should be an interesting experiment. |
Re: some observations need explanation
You try printing the address of i in each run of your program and see what is the value at that location and you will get the answer to your query.
|
Re: some observations need explanation
Good morning ,
since you have not implicitly given the value of 'i' or u have not initilized 'i' , so in 'i' every time u run the program , this 'i' will contain different garbage values......... thank u:pleased: |
| All times are GMT +5.5. The time now is 19:15. |