Skip to content

Added Array Question with Solution Code #536

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion Arrays/Arrays.md
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
## Arrays
## Arrays

Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value.

## Code To Read and Print elements of an array

```cpp
#include <stdio.h>
// Main function
int main()
{
int arr[10]; // Declare an array of size 10 to store integer values
int i;
// Print a message to prompt the user for input
printf("\n\nRead and Print elements of an array:\n");
printf("-----------------------------------------\n");
// Prompt the user to input 10 elements into the array
printf("Input 10 elements in the array :\n");
for(i=0; i<10; i++)
{
printf("element - %d : ",i); // Prompt the user to input the i-th element
scanf("%d", &arr[i]); // Read the input and store it in the array
}
// Display the elements in the array
printf("\nElements in array are: ");
for(i=0; i<10; i++)
{
printf("%d ", arr[i]); // Print each element in the array
}
printf("\n");
return 0;
}
```
10 changes: 7 additions & 3 deletions STL/Stack/pop() - Remove_Element.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
## Description
## Description

Element can be removed from last using pop method, remember it will remove the last element only.

## Method

```cpp
stack<int> first;
// Adding Element for demo
Expand All @@ -10,13 +12,15 @@ first.push(2);
first.push(4);
first.push(6);

// popping (removing) elements

// popping (removing) elements
first.pop(); // 6 removed
first.pop(); // 4 removed
```

### Stack now contains

```cpp
2
1
```
```