Run ❯
Get your
own
website
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
#include
using namespace std; // Global variable x int x = 5; void myFunction() { // Local variable with the same name as the global variable (x) int x = 22; cout << x << "\n"; // Refers to the local variable x } int main() { myFunction(); cout << x; // Refers to the global variable x return 0; }
22
5