readjusting code so the function works.

#include <iostream>
#include <string>
#include <cmath>

using namespace std;
int year1;
int year2;
int year3;
int month1;
int month2;
int month3;
int day1;
int day2;
int day3;
bool eldest1 = false;
bool eldest2 = false;
bool eldest3 = false;

int testleast(int a, int b, int c)
{
if (int a <= int b && int a <= int b)
{
return eldest1 = true;
}
else if (int b <= int c)
{
return eldest2 = true;
}
else
{
return eldest3 = true;
}
}

int main () {


// I have cin and cout as well in order to collect year (1,2,3), month (1,2,3), day (1,2,3)and some other code I am confident that works. It is only the function that comes up in error and this will save space. //

// the area below is comparing the input to find the eldest individual. I realize this doesn't account for all cases, but in the excluded code I do so. //

if (year1 == year2 == year3)
{
if (month1 == month2 == month3)
{
testleast(day1, day2, day3);
}
else
{
testleast(month1, month2, month3);
}
else
{
testleast(year1, year2, year3);
}
else
{
testleast (year1, year2, year3);
}
if (eldest1 = true)
{
cout << "Person 1 is the oldest";
}
else if (eldest2 = true)
{
cout << "Person 2 is the oldest";
}
else
{
cout << "Person 3 is the oldest";
}
return 0;
}

// I get a expected ) after int error for line if (int a <= int b && int a <= int b). Lastly, I get a expected a primary function before int. Any ideas how I should adjust my code so this function works? my apologies in regards to the format.
Last edited on
if (int a <= int b && int a <= int b)
u are redeclaring the variables.
just use
if (a <= b && a <= b)
correct it in other places as well, please use code tags and indent ur code before placing it next time.
Thanks.
Topic archived. No new replies allowed.