I need to write a program that tells whether it's a leap year or not. But I'm not quite sure how. If someone could point me in the write direction that'd be great thanks.
I've gotten this far but I'm a little stuck, any suggestions?
Ok well read through everything, and fixed some stuff. I think I forgot my {} on my statements, which I just missed for some reason. Should I use a string to fix my problem?
Sorry I'm trying my professor has a LOT of homework this week and I'm really trying hard to figure everything out.
But I'm still getting some errors, which are;
I know the statements have no effect because I haven't told them to do anything yet, but I'm trying to get the syntax errors out of way so I can start making it work.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp||In function `int main()':|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|12|error: `year' cannot be used as a function|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|16|error: `then' undeclared (first use this function)|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|16|error: (Each undeclared identifier is reported only once for each function it appears in.)|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|20|error: `year' cannot be used as a function|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|28|error: `year' cannot be used as a function|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|34|warning: statement has no effect|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|36|error: expected primary-expression before "else"|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|36|error: expected `;' before "else"|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|38|warning: statement has no effect|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|40|error: expected primary-expression before "else"|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|40|error: expected `;' before "else"|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|42|warning: statement has no effect|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|44|error: expected primary-expression before "else"|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|44|error: expected `;' before "else"|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|46|warning: statement has no effect|
||=== Build finished: 11 errors, 4 warnings ===|
Cleaned up the code more and got less errors. My if statements weren't properly enclosed.
Here's what I have so far anyone?
1 2 3 4 5 6 7 8 9 10 11 12 13 14
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp||In function `int main()':|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|12|error: `year' cannot be used as a function|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|15|error: `then' undeclared (first use this function)|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|15|error: (Each undeclared identifier is reported only once for each function it appears in.)|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|19|error: `year' cannot be used as a function|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|26|error: `year' cannot be used as a function|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|32|warning: statement has no effect|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|34|error: expected primary-expression before "else"|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|34|error: expected `;' before "else"|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|36|warning: statement has no effect|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|42|warning: statement has no effect|
C:\Users\Will\Documents\C++ Projects\LeapYear\main.cpp|48|warning: statement has no effect|
||=== Build finished: 7 errors, 4 warnings ===|
The modulo operator isn't (.
There's no "then" keyword.
The semicolons after else don't belong there.
Just writing a variable name on its own like "is_leap_year" doesn't actually do anything.
@Athar alright well I'm not quite sure how to implement that into my code can you help me out?
@Krofna Yeah I understand the normal C++ stuff, but this pseudo stuff I don't get my teacher has taught us nothing about it and he's like here read this wiki page and make a leap year program on top of 3 other programs due tomorrow. It's bs. That's why I'm asking for help I don't really get it. I'm not asking for a hand out, I've shown progress throughout this post. I'm just a little stuck and it's frustrating as hell.
but this pseudo stuff I don't get my teacher has taught us nothing about it
Because there's nothing to teach. There are no rules. It isn't a well-defined language, it's just some mix between English and something that looks like a programming language and is sometimes used to describe algorithms.
@Krofna: If you can't use your head from pseudo code to any programming language, you shouldn't be programming. Direct code for simple problems on this web site might be a class given project and most of us will not help but in pseudo code. This process is to learn how program the logic yourself. This is how I learned programming back when I was 12 and I didn't start in C++, just now have quite a bit in C++ now.
It makes much more sense now. Sometimes all it takes is a good example or some help and people can totally learn from it. I got it working and it was much easier than I thought. I over looked stuff, thanks for showing me.
@azagaros
Pseudo code is not pure english (read: croatian). Here in croatia it has some srs syntax and rules. Some is generaly correct, but most of it is wrong for any computer language.
I can translate pseudo code to c++ only beacuse I know c++. I was talking about other way around.
When I think about program I will write. It sounds nothing like the pseudo language from books. It pretty much sounds like mix of croatian, english with pieces of C++ syntax , NOT pseudo syntax
Pseudo code does 1 thing correctly: the obvious stuff such as if else and do while, and teaches you bad syntax. If you need pseudo code to teach you that....