Question: Create and debug this program in Visual C + + . Upload your Source.cpp file for testing. Write 3 functions: 1 . int readDoubleArray (
Create and debug this program in Visual C Upload your Source.cpp file for testing.
Write functions:
int readDoubleArray double d int size which reads numbers into double array d until size numbers have been read, or until the user types a nonnumeric, whichever comes first. Returns the number of array elements read.
Just before returning from the function, call
cin.clear; remove the fail condition caused by the nonnumeric
cin.ignore
; to empty the input buffer
double dotProductconst double a const double b int size which returns the sum of the products of aibi for arrays of length "size"
void printDoubleArray const double d int size which prints the numbers in d on a single line, separated by a comma and a space, terminated with endl
Your main program should:
Prompt the user to enter a list of numbers followed by a nonnumeric. Call readDoubleArray to put them into a double array already declared:
Ex:
Enter a list of numbers followed by a nonnumeric:
q
Prompt the user to enter a second list of numbers, with the same # of items as the first. followed by a nonnumeric. Call readDoubleArray to put them into another double array already declared: Ex:
Enter more numbers, same number of elements, followed by a nonnumeric:
g
Print the array contents using printDoubleArray then call dotProduct and print the results: Ex:
The dot product of:
and
is
If the user enters no numbers for either array, just a nonnumeric, print "Error: zero length array input" and exit the program. This error check should NOT be in readDoubleArray it should be in the main program when it checks the size returned by readDoubleArray: Ex:
Enter a list of numbers followed by a nonnumeric:
q
Error: zero length array input
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
