why output is 89????? why why why why why ........ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

why output is 89????? why why why why why ........

//---what is output #include<stdio.h> int i=10; void g() { i=89; printf("in g %d\n",i); } int main() { printf("%d\n",i); i=1; printf("%d\n",i); g(); printf("%d",i); return 0; }

18th May 2020, 5:47 AM
Ashutosh k.
Ashutosh k. - avatar
8 Answers
+ 3
Answer Try to understood how its working . Its not tricky very simple 10 1 in g 89 89
19th May 2020, 4:19 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
yes why 89 answer, function having void na avinesh
18th May 2020, 7:27 AM
Ashutosh k.
Ashutosh k. - avatar
+ 2
Here i is a global variable so it could be accessed and altered anywhere within this file. In void g() you assign i=89 so that is it's final value. If you access it anywhere, it will return the same.
18th May 2020, 7:32 AM
Avinesh
Avinesh - avatar
+ 2
Thanks avinesh
18th May 2020, 7:33 AM
Ashutosh k.
Ashutosh k. - avatar
+ 2
Thanks to all my friends, your efforts make me a good to great programer.
19th May 2020, 5:02 AM
Ashutosh k.
Ashutosh k. - avatar
+ 1
hello bro , i m totally frasted, that's why i put
18th May 2020, 6:37 AM
Ashutosh k.
Ashutosh k. - avatar
+ 1
help me if u can
18th May 2020, 6:37 AM
Ashutosh k.
Ashutosh k. - avatar
+ 1
Ashutosh k. How do you get the output 9?
18th May 2020, 7:19 AM
Avinesh
Avinesh - avatar