diff --git a/Arrays/Arrays.md b/Arrays/Arrays.md index d4182fb..1661a32 100644 --- a/Arrays/Arrays.md +++ b/Arrays/Arrays.md @@ -1 +1,33 @@ -## Arrays \ No newline at end of file +## 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 +// 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; +} +``` diff --git a/STL/Stack/pop() - Remove_Element.md b/STL/Stack/pop() - Remove_Element.md index 2de3c39..3fb78d8 100644 --- a/STL/Stack/pop() - Remove_Element.md +++ b/STL/Stack/pop() - Remove_Element.md @@ -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 first; // Adding Element for demo @@ -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 -``` \ No newline at end of file +```