Assignment for class on C Programming

This topic is 4275 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Share on other sites
Sorry, I doubt you'll get much help as homework questions are off-limits and your problems aren't the sort where effective 'hints' can be given.

And that seems maybe a little challenging for an introductory assignment, but not ridiculous.

Share on other sites
Even though this:
  if (grade > 100, < 0)
feels natural to write, you must specify grade twice and combine them with an 'or' operator ||, like this:
  if (grade > 100 || grade < 0)

Share on other sites
You have glaring syntactical errors, take five minutes and read your damn book instead of just guessing.

Share on other sites
Just a little hint, take a look at how to use if statements and how the braces go around them.

Besides that since it is a assignment we will not be much help. If you need help with logic or ideas on how to do it, we will help but as for writing or fixing your code, we won't. You will learn more if you find these problems, there is a lot to say for putting in the pain to find your syntax errors.

theTroll

Share on other sites
Wild_ponter, this is the newbie area, BE NICE. He may have read his book and just did not understand. We can nudge him in the right direction. No reason just to be insulting.

theTroll

Share on other sites
Quote:
 Original post by TheTrollWild_ponter, this is the newbie area, BE NICE. He may have read his book and just did not understand. We can nudge him in the right direction. No reason just to be insulting.theTroll

I agree. At least he obviously have made an attemt solving it for himself. And why force him to read the book when we can just tell him? 'He must learn to RTFM' you might respond, and you have a good point.

Share on other sites
Hints: I would re-read the sections on if statements, then logical operators, and then braces & statements.

Afterwards, you should be able to fix your problem.

Share on other sites
Quote:
 Original post by TheTrollWild_ponter, this is the newbie area, BE NICE.

Except that it isn't.

three6playa, the forum you want is called For Beginners, and is at the top of the forum list.

Also, we don't do homework questions here, although we certainly can help with understanding these sorts of things.

But I will try to be nice and also informative.

"parse error before '{' token" means exactly what it says: there is a "token" (either operator, other punctuation, variable name, keyword... some element of the syntax) on that line which is a '{' (opening brace), and at that point in the code this causes an error in "parsing" (if you don't know what that means, please look it up in a dictionary). Which is to say, you can't put a { at that point.

The problem is simply: sections of code enclosed with { and } are called "blocks". They are expected to nest, and a function consists of just one block. So in the main function, your } on line 9 ends the function. Then you have another { right away on line 10, and that is not inside main - it's an unnamed block of code in the middle of nowhere. You're not allowed to have those.