Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a code that receives a set of values from the user and sorts them. Apply printf and scanf - Ask the user how many

Write a code that receives a set of values from the user and sorts them. Apply printf and scanf

- Ask the user how many numbers they would like to enter (5-20).

- Check if the value they entered is within the range of 5-20. If not, ask them to enter a value between 5 and 20 until you receive a response in that range. Store this value in a variable named "N".

- When the user correctly enters N = the number of values (between 5-20), ask them for the first number. Tell them the number has to be between 1-100. Check if the number is between 1-100. If not, ask until they enter a number between 1-100.

- Repeat asking for new numbers and checking the validity of the numbers until the user enters the correct amount of numbers they specified in the beginning (N).

- Store these values in an array of size N. The name of the array should be "data".

- After the user finishes entering all the numbers, sort the numbers in ascending order using any exchange (swapping)-based sorting algorithm. Use a function named "sort" to accomplish the sorting, and within this function, call another function named "swap" to accomplish the swapping task. No part of the actual sorting or swapping should occur in the main function. You will need to pass the data array as a whole into the "sort" function. You will also need to pass two values that you are swapping to the "swap" function when needed.

- Print on the screen the numbers in ascending order.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions