Greetings,
I just got this email back from a teacher saying "the exercise asks you to show the values of all the array elements. Your output is a string of numbers with no spaces. I cannot identify the values of all the array elements. Make your output readable.
What? can you look and tell me am I wrong? I value all your input. I think its right but i am unsure of whats wrong with it?
Code:#include <iostream> //cin, cout, <<, >> #include <string> // for strings using namespace std; const int LITTLE = 6, //Word LITTLE equals 6 MEDIUM = 10, //Word MEDIUM equals 10 BIG = 128; //Word BIG equals 128 int i, j, n = 9, //integers with n being initalized to number 9. temp, number[MEDIUM] = { 99, 33, 44, 88, 22, 11, 55, 66, 77}; //array of numbers char ch, // characters letterCount[BIG]; // array BIG typedef double LittleDouble[LITTLE]; //redefined array LITTLE to LittleDouble LittleDouble value; int main() { for (i = 0; i < n - 1; i++) //initlaizes i = 0, n = 9, increase i. { for (j = i; j < n - 1; j++) //initlaizes j = 0, n = 9, increase i. if (number[j] > number[j + 1]) { temp = number[j]; number[j] = number[j + 1]; number[j + 1] = temp; } } cout << "this is for array number["<< j <<"] = " << number[j] << '\n' << "this is for array number["<< j+1 <<"] = " << number[j+1] <<'\n'; return 0; }



LinkBack URL
About LinkBacks


