-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Term Entry] local-variables #5496
[Term Entry] local-variables #5496
Conversation
[Term Entry] for Local Variables
- 'paths/computer-science' | ||
--- | ||
|
||
Local Variable is a variable in which it's scope is only limited to the function where it is defined. It exists and can only be accessed inside a function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Local Variable is a variable in which it's scope is only limited to the function where it is defined. It exists and can only be accessed inside a function. | |
**Local Variable** is a variable whose scope is only limited to the function where it is defined. It exists and can only be accessed inside a function. |
} | ||
``` | ||
|
||
The variable **`a_local_variable`** is local to the **`local_variable`** function it is defined in. It can only be used inside that function and the life of the variable ends when the function exits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable **`a_local_variable`** is local to the **`local_variable`** function it is defined in. It can only be used inside that function and the life of the variable ends when the function exits. | |
The variable `a_local_variable` is local to the `local_variable` function in which it is defined. It can only be used inside that function and the life of the variable ends when the function exits. |
|
||
## Example | ||
|
||
In the following example, a_local_variable of integer data type is defined inside the function local_variable(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the following example, a_local_variable of integer data type is defined inside the function local_variable(). | |
In the following example, the `a_local_variable` of integer data type is defined inside the function `local_variable()`. |
#include <iostream> | ||
using namespace std; | ||
void local_variable(){ | ||
int a_local_variable = 1; | ||
cout <<a_local_variable; | ||
} | ||
int main() | ||
{ | ||
local_variable(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <iostream> | |
using namespace std; | |
void local_variable(){ | |
int a_local_variable = 1; | |
cout <<a_local_variable; | |
} | |
int main() | |
{ | |
local_variable(); | |
} | |
#include <iostream> | |
using namespace std; | |
void local_variable(){ | |
int a_local_variable = 1; | |
cout <<a_local_variable; | |
} | |
int main() | |
{ | |
local_variable(); | |
} |
#include <iostream> | ||
using namespace std; | ||
void local(){ | ||
int var = 0; | ||
cout<<var; | ||
} | ||
int main() | ||
{ | ||
local(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <iostream> | |
using namespace std; | |
void local(){ | |
int var = 0; | |
cout<<var; | |
} | |
int main() | |
{ | |
local(); | |
} | |
#include <iostream> | |
using namespace std; | |
void local(){ | |
int var = 0; | |
cout<<var; | |
} | |
int main() | |
{ | |
local(); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Give a blank line after line 62
Hi @roberanegussie thank you for contributing to Codecademy docs, I have suggested a few changes please modify them. |
Dear @cigar-galaxy82 please review my changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing to Codecademy Docs @roberanegussie 😄
The entry looks good for a second round of review 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @roberanegussie ,
The entry is nicely written, Thank you for Contributing to Docs! :)
Thanks,
Savi
👋 @roberanegussie 🎉 Your contribution(s) can be seen here: https://www.codecademy.com/resources/docs/cpp/variables/local-variables Please note it may take a little while for changes to become visible. |
[Term Entry] for Local Variables
Description
I have added a term entry for the concept of cpp local variables.
Issue Solved
Closes #5470
Type of Change
Checklist
main
branch.Issues Solved
section.