Serial julian date

I have an error on line 7 this is what it is telling me.
I do not know if the code works because I can not build it. Any help will be greatly appreciated.
Error 1 error C2447: '{' : missing function header (old-style formal list?)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  include <iostream>

#include <cstdlib>
using namespace std;

int serial_julian_date(int month, int Day, int Year);

{ // this is where my error is .
	int a = (14 - Month) / 12;
	int m = Month + 12 * a - 3;
	int y = Year + 4800 - a;
	int nDate =
		Day + ((153 * m + 2) / 5) +
		365 * y + y / 4 - y / 100 + y + y / 400 - 32045;
	return nDate;

}
int main()
{
	

	
	cout
		<< "Enter the date in MM DD  YYYY(seperated by spaces)"
		<< "format(seperated by spaces) :";
	cout << "Serial Julian date is :";
	int Month;
	int Day;
	int Year;
	cout << serial_julian_date(7, 4, 1776) << '\n';
	keep_window_open();
	return 0;




}
Remove the semi-colon after the parenthesis and before the opening braces.

1
2
3
4
5
int serial_julian_date(int month, int Day, int
Year);   // <--- Remove this semi colon
{
    // this is where my error is .
}
Thanks I just started my C++ course with no knowledge of programing. Can someone tell me where the cin>> should be and what I should be putting in there. I am lost everything I have tried will not work. I can not get user input in .

#include "std_lib_facilities.h"
#include <iostream>
//function declaration
int serial_julian_date(int Month, int Day, int Year)
{
int a = (14 - Month) / 12;
int m = Month + 12 * a - 3;
int y = Year + 4800 - a;
int nDate =
Day + ((153 * m + 2) / 5) +
365 * y + y / 4 - y / 100 + y + y / 400 - 32045;
return nDate;
}



int main()
{

cout
<< "Enter the date in MM DD YYYY(seperated by spaces)"
<< "format(seperated by spaces)\n";

cout << "Serial Julian date is :" ;
cout << serial_julian_date(7, 14, 1446) << '\n';
keep_window_open();
return 0;
}
Judging by the way that you've coded so far, you would want something like this -

1
2
3
4
5
6
7
8
9
10
cout << "Enter the date in MM DD YYYY(seperated by spaces)" << endl;
	cout << "Serial Julian date is : ";

	int month, day, year;

	cin >> month >> day >> year; // user enters month, day and year seperated by space.

	int x = serial_julian_date(month, day, year); // call for the julian function. Give them the user info and catch the returning nDate with int x.

	cout << endl << x << endl; // print the shit out. 


I recommend you check out buckys (thenewboston) videos on youtube. He is fantastic at learning out the basics - https://www.youtube.com/playlist?list=PLAE85DE8440AA6B83
Last edited on
Hey thanks for the help , That is how I had it originally. Not as nicely coded. I am getting a year undefined error on the cin line that is stopping me from building it. Any ideas?

#include "std_lib_facilities.h"
#include <iostream>
//function declaration
int serial_julian_date(int Month, int Day, int Year)
{
int a = (14 - Month) / 12;
int m = Month + 12 * a - 3;
int y = Year + 4800 - a;
int nDate =
Day + ((153 * m + 2) / 5) +
365 * y + y / 4 - y / 100 + y + y / 400 - 32045;
return nDate;
}



int main()
{


cout
<< "Enter the date in MM DD YYYY(seperated by spaces)\n" << endl;
cout << "Serial Julian date is :" ;
int Month, Day, Year;
cin >> Month >> Day >> year; // error here
int x = serial_julian_date(Month, Day, Year);
cout << endl << x << endl;

keep_window_open();
return 0;
}
Last edited on
Uhm yeh. Look at the line above - int Month, Day, Year;

Its Year, with a big Y. on the line after you type in year, with a small y.

The "good programming practice" way of doing things is, most things is to be named by starting off with a lower case letter(meaning, if its only 1 word like year or month, just name it int year; int paparaja; etc), and if the variable or function name is 2 or more words, just start the other words with an upper case, something like this - int testingThisShit;

But not classes. You want classes to start with uppercase letter.
Last edited on
Wow I feel stupid! Thanks again for the help and I will take your "good programming practice" and use lower case.
Topic archived. No new replies allowed.