454,605 Members | 1,480 Online
Need help? Post your question and get tips & solutions from a community of 454,605 IT Pros & Developers. It's quick & easy.

# Very Lost and Very need of help

6 Replies

 P: 35 Any help please Nov 16 '06 #2

 100+ P: 142 Hi, You want to create print_inorder function to print the values from smaller to bigger right? Regards, M.Sivadhas. Nov 17 '06 #3

 P: 5 can u be more specific as to what you want to do? Nov 17 '06 #4

 Expert Mod 5K+ P: 8,916 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. So there are basically 2 things to do 1. Alter the prototype of swap_values. Can you do this re-wrte swap_values prototype to accept 3 parameters? 2. Change the logic that it implements. As an initial step to altering the logic it may be worth writing down (in English) the new logic that this function will implement. Once you you have an idea of the logic it needs to implement then you can actually have an attempt at implementing it. Nov 17 '06 #5

 P: 60 For sure this is what you want #include using namespace std; void swap_values(float & first, float & second, float &third) { float first_holder,second_holder,third_holder; if(first > second && first > third) { third_holder = third; first_holder = first; third = first; if(third_holder < second) first = third_holder; else { first = second; second = third_holder; } } else if(second > first && second > third) { third_holder = third; second_holder = second; third = second; if(first < third_holder) second = third_holder; else { second = first; first = third_holder; } } else { if(first > second) { first_holder = first; second_holder = second; first = second_holder; second = first_holder; } } } void print_inorder(float first, float second, float third) { cout<<"The first number is "<>first; cout<<"Enter the second number "; cin>>second; cout<<"Enter the third number "; cin>>third; swap_values(first,second,third); print_inorder(first,second,third); return 0 ; } Nov 17 '06 #6

 P: 35 For sure this is what you want #include using namespace std; void swap_values(float & first, float & second, float &third) { float first_holder,second_holder,third_holder; if(first > second && first > third) { third_holder = third; first_holder = first; third = first; if(third_holder < second) first = third_holder; else { first = second; second = third_holder; } } else if(second > first && second > third) { third_holder = third; second_holder = second; third = second; if(first < third_holder) second = third_holder; else { second = first; first = third_holder; } } else { if(first > second) { first_holder = first; second_holder = second; first = second_holder; second = first_holder; } } } void print_inorder(float first, float second, float third) { cout<<"The first number is "<>first; cout<<"Enter the second number "; cin>>second; cout<<"Enter the third number "; cin>>third; swap_values(first,second,third); print_inorder(first,second,third); return 0 ; } There should be two different codes Nov 17 '06 #7