CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

Global vs Local Variable

C code walkthrough · Question 8
mediumFunctions

Code

Read carefully. What does this print?
1#include <stdio.h>
2 
3int x = 10;
4 
5void change() {
6 int x = 20;
7 printf("%d\n", x);
8}
9 
10int main() {
11 printf("%d\n", x);
12 change();
13 printf("%d\n", x);
14 return 0;
15}

Your answer