I am trying to get this program to return a value, but it will not work. Can anyone help?
1.
#include <iostream>
2.
#include <iomanip>
3.
using namespace std;
4.
5.
int number_right (char let1, char let2, char let3, char let4, char let5, char let6);
6.
7.
int main ()
8.
{
9.
char let1 = 0, let2 = 0, let3 = 0, let4 = 0, let5 = 0, let6 = 0;
10.
//call test function
11.
number_right (let1, let2, let3, let4, let5, let6);
12.
13.
}
14.
15.
int number_right (char let1, char let2, char let3, char let4, char let5, char let6) /*function for number_right with six characters taken. Will
16.
return the number of chacter pairs that are a match*/
17.
{
18.
int set1 = 0; //setting set1 as a int, set at 0
19.
int set2 = 0; //setting set2 as a int, set at 0
20.
int set3 = 0; //setting set3 as a int, set at 0
21.
22.
cout << "Please enter six characters.\n"; //promt the user to enter in six characters
23.
cin >> let1 >> let2 >> let3 >> let4 >> let5 >> let6; //user enters six characters
24.
25.
if (let1 == let4) //if the first and fourth characters entered by the user are the same
26.
{
27.
cout << "The first letter is a match.\n"; //will cout notifying user that the numbers are a match
28.
set1 = set1 + 1; //add one to set1 if the characters are the same
29.
}
30.
if (let2 == let5) //if the second and fifth characters entered by the user are the same
31.
{
32.
cout << "The second letter is a match.\n"; //will cout notifying user that the numbers are a match
33.
set2 = set2 + 1; //add one to set2 if the characters are the same
34.
}
35.
if (let3 == let6) //if the third and sixth characters entered by the user are the same
36.
{
37.
cout << "The third letter is a match.\n"; //will cout notifying user that the numbers are a match
38.
set3 = set3 + 1; //add one to set3 if the characters are the same
39.
}
40.
else //if the characters do not match each other
41.
{
42.
cout << "There is no match.\n"; //advising the user that the characters do not match
43.
}
44.
45.
return (set1 + set2 + set3); //returning the additions of set1, set2 and set 3. This will return the correct amount of pairs matched
46.
}