How to call the function oreturn_days_in_month from main in c++? [closed]

  c++

I am sorry to ask about my homework, but I exhausted myself completely trying to solve it. I read, and reread the book, asked a professor, but as I’m working full time, I’m not making his office hours. Could you please point to what am I doing wrong here, as I am not getting the user input to go through the if/else loops, it always returns zero.
The program is supposed to return the number of days in the month.

    #include <iostream>
using namespace std;

long query_for_integer(string prompt) {
long answer = 0;

  cout << prompt;
  cin >> answer;

  return 0;
}

bool is_month_valid(long month){
bool return_value = false;
  if (month >= 1 && month <= 12){
    return_value = true;
  }
  else{
    return_value = false;
  }
  return 0;
}

bool is_a_leap_year(long year){
bool return_value = false;
  if ( (year % 400 ==0) || ((year % 4 == 0) && (year % 100 != 0))){
      return_value = true;
      }
  else{
      return_value = false;
    }
    return return_value;
}

long return_days_in_month(long month, long year){
  if (month == 2){
    if (is_a_leap_year(year) == true){
      return 29;
    }
    else if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12){
      return 31;
    }
    else{
      return 30;
    }
  }
  }



int main(){

//long day = 0;
long month = 0;
long year = 0;
//long days_in_month =0;


  year =  query_for_integer("Enter a year: ");
  month = query_for_integer("Enter a month: ");
 // day = query_for_integer("Enter a day: ");
 
  cout << "The number of days is " << return_days_in_month(month, year);
}

Source: Windows Questions C++

LEAVE A COMMENT