logo

Local vs global variables in C

#include <stdio.h> #include <stdlib.h> #include <string.h> int y = 5; int x; void f1() { if (y == 5) { x = 10; } else { x = 15; } printf("Value of x is %d\n", x); } int main(int argc, char **argv) { f1(); return 0; }