Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I wrote a code in visual studios c++ that does the following: - Ask the user how many numbers they would like to enter (5-20).

I wrote a code in visual studios c++ that does the following:

- 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.

code:

#include using namespace std; void swap(double *xp, double *yp) { double temp = *xp; *xp = *yp; *yp = temp; } void sort(double arr[], int n) { int i, j, min_idx; for (i = 0; i for (j = i+1; j if (arr[j] while(N20) { cout>N; if (N20) { coutfor(int i=0; iwhile (data[i]100 ) { cout>data[i]; } } sort(data,N); coutfor(int i=0; ireturn 0; } <><>

but I keep getting error messages that state the following:image text in transcribedThese error messages stop the visual studio compiler from running the code. It will not let run the code I am obligated ti use visual studios. Is there anyway to fix the code to prevent these error messages from popping up. Or if it is possiple to write a similar code that excutes the following tasks and can work without error messages of microsoft visual studios.

ConsoleApplication7 ConsoleApplication7.cpp 46 ConsoleApplication7consoleapplication7.cpp 46 ConsoleApplication7 consoleapplication7.cpp 49 ConsoleApplication7consoleapplica7cpp 53 ConsoleApplication7consoleapplication7.cpp 61 E0028 expression must have a constant value C2131 expression did not evaluate to a constant C3863 array type double [NJ is not assignable c4552 . >>": operator has no effect, expected operator with side-effect c4552 .

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

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

Students also viewed these Databases questions

Question

LOQ 12-14: What predicts happiness, and how can we be happier?

Answered: 1 week ago

Question

5. Identify the logical fallacies, deceptive forms of reasoning

Answered: 1 week ago

Question

6. Choose an appropriate organizational strategy for your speech

Answered: 1 week ago