Examples of Arrays Between Programming Languages

https://shelleygrayteaching.com/arrays-what-are-they-and-why-do-we-use-them/

Arrays

History

Benefit and downside

Application and User

Python

import array as arr
numbers_list = [2, 5, 62, 5, 42, 52, 48, 5]
numbers_array = arr.array('i', numbers_list)
print(numbers_array[2:5]) # 3rd to 5th
print(numbers_array[:-5]) # beginning to 4th
print(numbers_array[5:]) # 6th to end
print(numbers_array[:]) # beginning to end

Output

array('i', [62, 5, 42])
array('i', [2, 5, 62])
array('i', [52, 48, 5])
array('i', [2, 5, 62, 5, 42, 52, 48, 5])

JavaScript

Inputclass Main {
public static void main(String[] args) {
// create an array
int[] age = {12, 4, 5};
// loop through the array
// using for loop
System.out.println("Using for Loop:");
for(int i = 0; i < age.length; i++) {
System.out.println(age[i]);}}}
OutputUsing for Loop:
12
4
5

C/C++

#include <iostream>
using namespace std;
int main() {
int numbers[5] = {7, 5, 6, 12, 35};
cout << "The numbers are: ";
// Printing array elements
// using range based for loop
for (const int &n : numbers) {
cout << n << " ";
}cout << "\nThe numbers are: ";
// Printing array elements
// using traditional for loop
for (int i = 0; i < 5; ++i) {
cout << numbers[i] << " ";
}
return 0;
}

Output

The numbers are: 7  5  6  12  35
The numbers are: 7 5 6 12 35

Conclusion

--

--

--

Seattle Website Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The Foundations for Building an Apache Flink Application

Vote For Your Favorite Grant Projects

Running a simple and effective retrospective meeting remotely

The Vital Importance of Trolls: On the Positive Benefits of Adversarial Communication

Mining Labs — Litepaper

Tell us about something you learned this week.

Esportsref progress update

How to No Permission named for guard web in Laravel

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Website Developer

Website Developer

Seattle Website Developer

More from Medium

How are C++ Objects Laid in Memory? | Accessing private attributes of C++ classes

Linux: Software libraries in C

Functors in C+ ;Simple Explanation by Examples

Move-in-move-out in C++