Question: I do not understand what I need to do on this assignment. It states: View the code in the file LoopingArrays.cpp (in the Course Information

I do not understand what I need to do on this assignment. It states: View the code in the file LoopingArrays.cpp (in the Course Information area). Although the program compiles and runs, notice how difficult it is to read the code itself. Part of programming is making your code readable so other developers can read and maintain it. I am still learning but I don't understand why this code is messy.

// LoopingArrays.cpp : This program loops through to create an array based on user input and then // sorts the array in order of smallest integer to largest. Format the code following the code // styling document. //

#include "stdafx.h" #include #include using namespace std;

void main() { int array[10], t; for (int x = 0; x<10; x++) { cout << "Enter Integer No. " << x + 1 << " : " << endl; cin >> array[x]; } for (int x = 0; x<10; x++) { for (int y = 0; y<9; y++) { if (array[y]>array[y + 1]) { t = array[y]; array[y] = array[y + 1]; array[y + 1] = t; } } } cout << "Array in ascending order is : "; for (int x = 0; x<10; x++) cout << endl << array[x]; return; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!