![]() |
Help with code (C++)
Ive been behind and i just got an assignment but dont know how to do it so im gonna ask for some help.
The instructions are as follow: 1. Name the program ch4grade.cpp 2. Make sure the program name and the author's name is in comments at the top of the page 3. Put COMMENTS before EACH SECTION 4. Declare 5 char constants: GRADE_A initialized to 'A' thru GRADE_F initialized to 'F' --- compile your program here --- 5. Declare a char variable named myGrade --- compile your program here --- 6. Assign the grade you'd like to recieve in this class to my_grade equal to in one of the constants GRADE_A thru GRADE_F. --- compile your program here --- 7. Display your grade with a cout statement that says something like: My name is xxxx. The grade I'd like to recieve in C++ is... -- compile and run your program --- I have no clue on how to do any of this... |
Not trying to be rude, however, how did you make it to Chapter 4 without knowing how to:
1. Name a program ch4grade.cpp 2. Make sure a program name and the author's name is in comments at the top of the page 3. Put COMMENTS before EACH SECTION 4. Declare char constants: 5. Declare char variables... ;) |
Well this is the first actuall program we have done lol the class/teacher is not very good and I have not learned anything.
|
Do you have a book? Cause that's how I learned all my stuff.
Try writing the program first, because it's a pretty easy assignment. If you have troubles after writing it, post your code on here, and someone will be able to help. |
yeah buddy, if we help u out with stuff like this, you will never get anywhere.
i say you turn to the section on variable declarations and take it on from there. good luck :D |
Alright well thanks for not just giving me the answer and giving me some advice instead. Ill get the book and try it.
|
declaring a variable is an easy process:
typeofvar varname = initializedvalue; for constants, like your GRADE_A - GRADE_F, you want to use the const modifier so the program cannot change the values after they have been initialized. Assigning values is a simple mathematical operation, so Ill leave that out. As far as printing, there are a few functions you can use, I reccoment you lookup the man pages (or go online) for cout. Oh yeah, and read through that book... |
So far ive got
So far for my code i have
Quote:
|
Your compiler should give you hints; always start with the top error in the list and recompile.
Here's what I see at a glance: int grade. b;//b will be used to hold age Should be: int grade, b;//b will be used to hold age and you need a semicolon at the end of your cout statement |
Thanks
|
Fixed um all and its runs fine thanks for all the help... I jsut got another assignment so will probably have some more questions.
|
what youu really need is to learn cpp SYNTAX!!!
get any book and read the 1st few chapters...atleast the semicolon/;, stuff will be clear |
Quote:
which compiler are you using? i think you can download borlands compiler for free after registering on their site devCPP is also a free compiler |
We are using borland im sick today kinda feelin run down not gonna do much ill get back to it tomorrow.
|
All times are GMT -8. The time now is 05:20 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project