C++ Question... •Create a program that •Stores multiple sequences of double valu
ID: 3802212 • Letter: C
Question
C++ Question...
•Create a program that
•Stores multiple sequences of double values
•Computes the minimum value, the maximum value, the sum of all values in the sequence, and the mean of the values in the sequence
•Displays a menu that gives the user the following options
•Add a new sequence to memory
•Ask the user how many numbers will be stored in this sequence
•Proceed to ask them for the numbers one at a time
•List existing sequences stored in memory (program starts with none)
•It prints the sequence index number and how many values are part of the sequence (but not the actual values)
•Print an existing sequence in memory
•Asks the user for the index of the sequence
•Print all the numbers in the sequence, as well as its minimum, maximum, sum, and mean
Quit (exits program)
CANNOT USE VECTOR BUT CAN USE POINTERS
Explanation / Answer
include //Always use meaningful names for types typedef unsigned char boolean; #define True 't' #define FALSE (!True) //this is a really neat trick for swapping values efficiently void swap(long* a,long *b) { *a=*a^*b;*b=*b^*a;*a=*a^*b; } //Here's a readability improvement #define until(condition) while(!(condition)) int main(int n, char*args[]){ double *d; int i; char input[5]; //should be long enough for most doubles. boolean sorted = FALSE; //In C, you need to specify the array size beforehand, so ask printf("Please enter the length of the array "); gets(input); //scan the input string and convert to a value sscanf(input,"%s",&input[0]); n=(long)atol(input); //allocate space, make sure you get the order of arguments right. d = calloc(sizeof(double),n); //Get and sort the array until (sorted) { for (i=0;iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.