Write a program that reads its input into an array

Assignment Help Programming Languages
Reference no: EM132211449

Question: Write a program that reads its input into an array and then uses selection sort to sort the array. In selection sort, we first find the smallest element in the array and exchange it with the first array element's value; then we find the next smallest element in the array and exchange it with the second array element's value; and so on, until the array is sorted.

Have your program include 4 functions, besides main, which perform the following functions:

1. Read in an undetermined number of array elements.

2. Print the array elements (call this function both before and after the elements are sorted).

3. Sort the array elements.

4. Swap two elements of an array (this function will be called by your sort function).

Do not use any jump statement, e.g., the break statement.

Declare the maximum array size as a constant MAXSIZE with a value of 10.

Run your program with the following set of input:

1. 5 12 -7 3 0

2. 1 2 3 4 5 7 6

3. Some input that will trigger each of your errors checks, what happens when you enter more values than MAXSIZE or when invalid (nonnumeric) data is entered. Flush the invalid data and continue reading until EOF or the array is full. Print appropriate error message for invalid character data and for too many values. Data items should still be sorted, even if invalid character data is encountered or too many values are entered.

Reference no: EM132211449

Questions Cloud

Write a program that reads ten numbers from the screen : Write a program that reads 10 numbers from the screen, calculates the mean (average), finds the minimum and maximum values, and outputs them to the screen.
Create a list of these numbers and find the arithmetic mean : Write a program for: In a text file INPUT integers separated by a space, perhaps in a few lines.
Write a program that reads a file of dna data : Write a program that reads a file of DNA data and searches for protein sequences. DNA data consists of long strings of the letters A,C,G, and T.
Write a program that takes two non-negative integers : Write a program that takes two non-negative integers from standard input and calculates their greatest common divisor (gcd).
Write a program that reads its input into an array : Write a program that reads its input into an array and then uses selection sort to sort the array. In selection sort, we first find the smallest element.
Write a program that can be used by a small theater : Write a program that can be used by a small theater to sell tickets for performances.
Calculate team a record at the end of the season : Write a program that reads file called bballscores.txt containing the score of Team A's basketball games. The file will contain two numbers per line.
Create an array that will store input data for daily sales : Write a program using an array that will process sales data for a week. Create an array that will store input data for the daily sales for a week (7 days).
Write a program using an array of records : Write a program that will read the radii of circles. Use an array of records where each record will have the radius of the circle read from the keyboard.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd