beginner

write a C++ program to read two distances for each face, compute the ratios, and then determine which two images have the closest ratio.
Can someone point me the mistakesss i made in this code?thank you.

[code]
#include <iostream>
using namespace std;
double ratio (int a, int b, int c, int d, int e, int f)
int main()
{
double eye distance;
double nose to chin distance;
cout<<"Enter value in cm.";
cout<<"Enter eye distance and nose to chin distance for image 1:";
cin>>eye distance, nose to chin distance;
cout<<"Enter eye distance and nose to chin distance for image 2:";
cin>>eye distance, nose to chin distance;
cout<<"Enter eye distance and nose to chin distance for image 3:";
cin>>eye distance, nose to chin distance;
double aspect= eye distance, nose to chin distance
cout<<"Best matches is between<<"aspect ration"<<aspect<endl;
return 0;
}
//missing semicolon to indicate end of function prototype declaration
//you just need to include the types of the parameters, not names in a prototype
double ratio (int a, int b, int c, int d, int e, int f)

//make variable names one word
double eye distance;
double nose to chin distance;

//what calculation are you trying to do to assign to aspect?
double aspect= eye distance, nose to chin distance

//missing< in front of <endl
//not sure what you mean to do with the rest. The <<" is generating an error. Is the result of the ration function //supposed to come in here?
cout<<"Best matches is between<<"aspect ration"<<aspect<endl;

//need >> before each input
cin>>eye distance, nose to chin distance;
cin >> eyedistance >> nosetochindistance;
Last edited on
Thanks for correcting me all the way!
and yea im a real new beginner, and i have no idea on how to code the program that it can calculates the ratio and compare them. so can you help me on this?
A ratio is going to be something divided by something - in this case, perhaps the distance between the eyes divided by the distance between the nose and chin? Were you given a specific formula?

Then it sounds like you want to find the two ratios out of the three calculated that have the smallest difference between them. So I might use the absolute value function in <cmath> and get the absolute differences between ratio 1 and 2, ratio 2 and 3, and ratio 1 and 3. Then find the smallest value in those three differences.


Thanks for helping!^^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
using namespace std;

double ratio (int a, int b, int c, int d, int e, int f);  // semicolon missing

int main()
{
    double eye_distance;
    double nose_to_chin_distance;
    cout<<"Enter value in cm.";
    cout<<"Enter eye distance and nose to chin distance for image 1:";
    cin>> eye_distance >> nose_to_chin_distance;
    cout<<"Enter eye distance and nose to chin distance for image 2:";
    cin>> eye_distance >> nose_to_chin_distance;
    cout<<"Enter eye distance and nose to chin distance for image 3:";
    cin>> eye_distance >>  nose_to_chin_distance;
    double aspect= eye_distance, nose_to_chin_distance;
    cout<<"Best matches is between" <<"aspect ration"<<aspect<< endl;
    return 0;
}


There, I fixed it. You should use _ (underscore for expressing space.)
This is really* important.

I really don't have time to question you about all this parts, but I can tell you one thing. Please remember the basic syntax.

Also, please indent! Indenting helps other people read and understand the code easily.

double aspect is really dangerous. double aspect has the value of eye distance, but nose to chin distance is not identified. I think you should get enough errors for those mistakes.
Last edited on
Topic archived. No new replies allowed.