I'm suppose to edit the function called swap_values so that it receives three numbers (not two nubmers) called first , second, and third. These numbers will not be in any special order (for example enter 20.0, 3.1 and 9.3). The function swap-values will need to be edited to use more "if" statements to place the smallest vlaue in the variable named first, the second smallest number in the variable named second, and the largest number in the variable named third.
You are also to edit the cout statements to print all three nubmers in the correct order (the variable first will be printed first and have in it the smallest number, the variable second will be pritned next and will have the middle number in it and the variable third will be prited last and have the largest number in it). Than take the cout statements (that print the three numbers in order) and create another another function called print_inorder. This new function will print the numbers in order from smallest to largest.
You are also to edit the cout statements to print all three nubmers in the correct order (the variable first will be printed first and have in it the smallest number, the variable second will be pritned next and will have the middle number in it and the variable third will be prited last and have the largest number in it). Than take the cout statements (that print the three numbers in order) and create another another function called print_inorder. This new function will print the numbers in order from smallest to largest.
Code:
# include <iostream.h> // recall function definitions can be written either before or after the main void swap_values (float &a, float &b) { float temp; temp = a; a = b; b = temp; } void main (void) { void swap_values (float &, float &); //prototype float first = 10000.0; float second = 0.00001; swap_values(first, secondl); // function call statement cout << “Big contains “ << big << endl; cout << “Small contains “ << small << endl; } //end of code to swap two numbers
At the top of the program insert comments that contain the assignment number, question number, and your name
Edit the addThree function and change its name to useTwo.
Edit the useTwo function accept only two float numbers
Within the useTwo function add additional code to
calculate the sum, product, quotient and subtraction value of the two floats entered.
Return the 4 math answers calculated in the useTwo function to the main along with the two floats used to get the answers.
Edit the printResults to receive 6 floats, the two numbers entered in the useTwo function the the 4 math answers calcualted in the useTwo fucntion. The printResults function should be edited to include the code to print all 6 numbers, formatted, and clearly labeled.
Edit the addThree function and change its name to useTwo.
Edit the useTwo function accept only two float numbers
Within the useTwo function add additional code to
calculate the sum, product, quotient and subtraction value of the two floats entered.
Return the 4 math answers calculated in the useTwo function to the main along with the two floats used to get the answers.
Edit the printResults to receive 6 floats, the two numbers entered in the useTwo function the the 4 math answers calcualted in the useTwo fucntion. The printResults function should be edited to include the code to print all 6 numbers, formatted, and clearly labeled.
Code:
# include <iostream.h> // recall function definitions can be written either before or after the main void addThree (float &a, float &b, float &c, float &s) { cout<<”enter number 1: “; cin>>a; cout<<”enter number 2: “; cin>>b; cout<<”enter number 3: “; cin>>c; s = a + b + c; } void printResults (float a, float b, float c, float s) { cout<<”number 1 = “<<a<<endl; cout<<”number 2 = “<<b<<endl; cout<<”number 3 = “<<c<<endl; cout<<”sum = “<<s<<endl; } void main (void) { void addThree (float &a, float &b, float &c, float &s) ; // prototype void printResults (float a, float b, float c, float s); // prototype float num1, num2, num3, sum; addThree (num1, num2, num3, sum); // call statement printResults(num1, num2, num3, sum);// call statement } //End of Code
Comment