background: intro C++ student.
we needed to create a library with the (- void increasing (double& A, double& B, double& C); //Arranges A, B, and C in increasing order.)
so here's what I came up with
Library
(header file)
void increasing(double& A, double& B, double& C); //Arranges A, B, and C in increasing order.
#include <iostream>
usingnamespace std;
void increasing(double& A, double& B, double& C)
{
double small, medium, large;
if ((A <= B) && (A <= C) && (B <= C))
{
small = A;
medium = B;
large = C;
}
if ((A <= B) && (A <= C) && (B >= C))
{
small = A;
medium = C;
large = B;
}
if ((A <= B) && (A >= C) && (B <= C))
{
small = B;
medium = A;
large = C;
}
if ((A >= B) && (A <= C) && (B <= C))
{
small = B;
medium = A;
large = C;
}
if ((A >= B) && (A >= C) && (B <= C))
{
small = B;
medium = C;
large = A;
}
if ((A >= B) && (A <= C) && (B >= C))
{
small = C;
medium = A;
large = B;
}
if ((A >= B) && (A >= C) && (B >= C))
{
small = C;
medium = B;
large = A;
}
if ((A <= B) && (A >= C) && (B >= C))
{
small = A;
medium = B;
large = C;
}
if ((A <= B) && (A >= C) && (B >= C))
{
small = C;
medium = A;
large = B;
}
A = small;
B = medium;
C = large;
return;
}
and then we're supposed to (Use the library in a program where the user is asked to enter three numbers. The program calls all three functions above and outputs the new values of A, B, and C for each case.)
so I made this
(program)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include "ughh.h"
#include<iostream>
usingnamespace std;
void increasing(double& A, double& B, double& C);
int main()
{
double A, B, C, please;
cout << "Enter 3 numbers:";
cin >> A >> B >> C;
please = increasing(double& a, double& b, double& c);
cout << "Arranged in increasing order:" << please << endl;
system("pause");
return 0;
}
now everything seems to be working alright except for an error in the line
please = increasing(double& a, double& b, double& c);
When calling the function you must not mention the parameter types. You also need to spell the variables correctly. C++ is case-sensitive so a is not the same variable name as A.