Skip to content

Instantly share code, notes, and snippets.

@mattsegura
Created November 26, 2020 07:39
Show Gist options
  • Save mattsegura/989f34aec6237bc39dddb6b0a019759a to your computer and use it in GitHub Desktop.
Save mattsegura/989f34aec6237bc39dddb6b0a019759a to your computer and use it in GitHub Desktop.
simple array program demonstration, using string array and taking input from an array integer
#include <iostream>
#include <string>
using namespace std;
int main()
{
string myArray[3] = {"red", "blue", "orange"};
int numArray[5];
cout << myArray[0] << " ";
cout << myArray[1] << " ";
cout << myArray[2] << " ";
cout << "\nEnter 5 numbers: \n";
cin >> numArray[0] >> numArray[1] >> numArray[2] >> numArray[3] >> numArray[4];
cout << numArray[0] << " " << numArray[1] << " " << numArray[2] << " " << numArray[3] << " "
<< numArray[4] << "\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment