#include #include using namespace std; //Find the lowest 2021 median family income of all the states. //https://en.wikipedia.org/wiki/List_of_U.S._states_and_territories_by_income // //The variable "smallest" will be the subscript of the smallest number //in the array. int main() { int a[] { 53913, //Alabama 77845, //Alaska 69056, //Arizona 52528, //Arkansas 84907, //California 82254, //Colorado 83771, //Connecticut 71091, //Delaware 63062, //Florida 66559, //Georgia 84857, //Hawaii 66474, //Idaho 72205, //Illinois 62743, //Indiana 65600, //Iowa 64124, //Kansas 55573, //Kentucky 52087, //Louisiana 64767, //Maine 90203, //Maryland 89645, //Massachusetts 63498, //Michigan 77720, //Minnesota 48716, //Mississippi 61847, //Missouri 63249, //Montana 66817, //Nebraska 66274, //Nevada 88465, //New Hampshire 89296, //New Jersey 53992, //New Mexico 74314, //New York 61972, //North Carolina 66519, //North Dakota 62262, //Ohio 55826, //Oklahoma 71562, //Oregon 68957, //Pennsylvania 74008, //Rhode Island 59318, //South Carolina 66143, //South Dakota 59695, //Tennessee 66962, //Texas 79449, //Utah 72431, //Vermont 80963, //Virginia 84247, //Washington 51248, //West Virginia 67125, //Wisconsin 65204 //Wyoming }; int n {size(a)}; //the number of elements in the array if (n == 0) { cerr << "The array is empty, so it has no smallest element.\n"; return EXIT_FAILURE; } int smallest {0}; //Temporarily assume that the 1st element is smallest. for (int i {1}; i < n; ++i) { //Now examine the rest of the elements. if (a[i] < a[smallest]) { smallest = i; } } //Wish we could also output the name, not just the subscript number. cout << "The smallest element is " << a[smallest] << " located at subscript " << smallest << ".\n"; return EXIT_SUCCESS; }