What are local variables in C++?

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.


Live Demo

#include <iostream>
using namespace std;
int main () {
   int a, b;
   int c;
   a = 10;
   b = 20;
   c = a + b;
   cout << c;
   return 0;


This will give the output −

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know