Skip to content
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

Merged
merged 25 commits into from
Nov 12, 2024

Conversation

roberanegussie
Copy link
Contributor

[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

  • Adding a new entry

Checklist

  • All writings are my own.
  • My entry follows the Codecademy Docs style guide.
  • My changes generate no new warnings.
  • I have performed a self-review of my own writing and code.
  • I have checked my entry and corrected any misspellings.
  • I have made corresponding changes to the documentation if needed.
  • I have confirmed my changes are not being pushed from my forked main branch.
  • I have confirmed that I'm pushing from a new branch named after the changes I'm making.
  • I have linked any issues that are relevant to this PR in the Issues Solved section.

[Term Entry] for Local Variables
@cigar-galaxy82 cigar-galaxy82 self-assigned this Oct 15, 2024
@roberanegussie roberanegussie changed the title [Term Entry] local-variables.md [Term Entry] local-variables Oct 16, 2024
- '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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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().
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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()`.

Comment on lines 32 to 41
#include <iostream>
using namespace std;
void local_variable(){
int a_local_variable = 1;
cout <<a_local_variable;
}
int main()
{
local_variable();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#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();
}

Comment on lines 52 to 61
#include <iostream>
using namespace std;
void local(){
int var = 0;
cout<<var;
}
int main()
{
local();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#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();
}

Copy link
Contributor

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

@cigar-galaxy82
Copy link
Contributor

Hi @roberanegussie thank you for contributing to Codecademy docs, I have suggested a few changes please modify them.

@cigar-galaxy82 cigar-galaxy82 added c++ C++ entries new entry New entry or entries status: review 1️⃣ completed status: waiting for author status: under review Issue or PR is currently being reviewed hacktoberfest-accepted Indicates the PR was approved, merged, and pertains to Hacktoberfest labels Oct 20, 2024
@roberanegussie
Copy link
Contributor Author

Dear @cigar-galaxy82 please review my changes.

Copy link
Collaborator

@mamtawardhani mamtawardhani left a 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 🚀

@SaviDahegaonkar SaviDahegaonkar self-assigned this Nov 7, 2024
@mamtawardhani mamtawardhani added status: under review Issue or PR is currently being reviewed and removed status: ready for next review labels Nov 7, 2024
Copy link
Contributor

@SaviDahegaonkar SaviDahegaonkar left a 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

@Radhika-okhade Radhika-okhade merged commit 30f0711 into Codecademy:main Nov 12, 2024
6 checks passed
Copy link

👋 @roberanegussie
You have contributed to Codecademy Docs, and we would like to know more about you and your experience.
Please take a minute to fill out this four question survey to help us better understand Docs contributions and how we can improve the experience for you and our learners.
Thank you for your help!

🎉 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.
If you're appearing as anonymous and want to be credited, see here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ C++ entries hacktoberfest-accepted Indicates the PR was approved, merged, and pertains to Hacktoberfest new entry New entry or entries status: review 1️⃣ completed status: under review Issue or PR is currently being reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Term Entry] C++ Variables Local Variables
5 participants