Variables that are declared inside a function or block are local variables. They can be used only by statements that are inside that function or block of code. Local variables are not known to functions on their own.
Example
#include <iostream>
using namespace std;
int main () {
int a, b;
int c;
a = 10;
b = 20;
c = a + b;
cout << c;
return 0;
}Output
This will give the output −
30