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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

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
}
```

The output of the above code will be:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Give a line gap after line 44

- '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
Collaborator

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
Collaborator

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
Collaborator

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
Collaborator

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
Collaborator

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
Collaborator

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
Collaborator

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.

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 status: waiting for author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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