02-03-2004, 05:56 AM | #1 (permalink) |
Registered User
|
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... Last edited by PoteMatic; 02-03-2004 at 06:17 AM.. |
02-03-2004, 06:09 AM | #2 (permalink) |
Bokonist
Location: Location, Location, Location...
|
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...
__________________
"Beware of the man who works hard to learn something, learns it, and finds himself no wiser than before. He is full of murderous resentment of people who are ignorant without having come by their ignorance the hard way." -Kurt Vonnegut |
02-03-2004, 09:13 AM | #5 (permalink) |
The GrandDaddy of them all!
Location: Austin, TX
|
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
__________________
"Luck is what happens when preparation meets opportunity." - Darrel K Royal |
02-03-2004, 09:28 AM | #7 (permalink) |
Banned
Location: UCSD, 510.49 miles from my love
|
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... |
02-04-2004, 06:32 AM | #8 (permalink) | |
Registered User
|
So far ive got
So far for my code i have
Quote:
|
|
02-04-2004, 06:41 AM | #9 (permalink) |
Insane
Location: West Virginia
|
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
__________________
- Artsemis ~~~~~~~~~~~~~~~~~~~~ There are two keys to being the best: 1.) Never tell everything you know |
02-04-2004, 10:21 AM | #12 (permalink) |
Junkie
Location: India
|
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
__________________
Why did the Comp. Engineer get X-mas and Halloween mixed up? Because Oct(31) == Dec(25) |
02-04-2004, 10:26 AM | #13 (permalink) | |
Junkie
Location: India
|
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
__________________
Why did the Comp. Engineer get X-mas and Halloween mixed up? Because Oct(31) == Dec(25) |
|
Tags |
code |
|
|