#include <cstdio> const float Pi = 3.14; float calc_area(float radius); int main() { int x, y; ... } float calc_area(float radius) { float area; ... }
void function_one(int x) { float y; } void function_two(char x) { int y; }
2
, as the
variable accessed is the one local to main
:
#include <cstdio> int X = 1; int main() { int X = 2; printf("%d\n", X); }
A profusion of global variables increases the likelihood of mistakes in two major ways:
#include <cstdio> const float Pi = 3.14; const int TRUE = 1; const int FALSE = 0; typedef int Boolean; float calc_area(); int main() { ... } float calc_area() { ... }