Question
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:
#includeusing 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; i while (data[i]100 ) { cout>data[i]; } } sort(data,N); coutfor(int i=0; i return 0; } <><>
but I keep getting error messages that state the following:These 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started