|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 | ||||
|
Member (9 bit)
|
Need some help with a Programming Code...PLEASE!
Ok, I'm using Dev C++ game programming software and I need someone to help me write a code... this is what my teacher gave me, sorry if it's not too clear I really don't understand it..
Ok; Quote:
Quote:
-Edit- Here is a code I just tryed and it gave me a couple of errors; Quote:
Quote:
__________________
< Antec 1200 | ASUS Rampage III Extreme | Intel Core i7-920 w/ Noctua cooler @ 3.1 GHz | Corsair Dominator's 6GB| (2) Sapphire HD 5770's in CrossfireX | WD Raptor 74GB | WD Caviar Black 1TB | Corsair HX850W > |
||||
|
|
|
|
|
#2 |
|
Barefoot on the Moon!
Staff
Premium Member
Join Date: Aug 2002
Location: Northeastern USA
Posts: 13,385
|
I don't know C++, but it looks like you have a parenthesis instead of a bracket below the constructor for int main(). That may take care of one of the errors.
__________________
There are two secrets to staying young, being happy, and achieving success. You have to laugh and find humor every day, and you have to have a dream.
|
|
|
|
|
|
#3 |
|
Member (9 bit)
Join Date: Jan 2004
Location: Kansas City(westwood), KS
Posts: 458
|
I know exactly how to do this in java but c++ isn't something i've messed with it. One thing i can't help but notice, it doesn't look like you multiply anywhere in there and product means multiplication. I can show you the java code if you like but you'd have to know how to adapt it.
EDIT Also i see you declare first_num as a variable but i don't see you declare second_num anywhere. |
|
|
|
|
|
#4 |
|
Member (9 bit)
|
Yeah, I can try the Java Code if you can give it that would be great.
Let me mess with it some more... |
|
|
|
|
|
#5 |
|
Member (9 bit)
Join Date: Feb 2005
Posts: 392
|
change "(" to "{" after "int main()"
first off variable "second_num" is not declared; you have to declare a variable before you can use it in C++; like "int second_num;" it also has no input statement, meaning no value.you need some thing like: cin >> second_num; now for the output: what the hell is ".h" anyway?????(sorry for the language) you probably mis-read it from ".\n" adding( SUM ) output statement should be: cout << "The sum of " << first_num << " and " << second_num << " is " << first_num+second_num << ".\n"; for multiplying(PRODUCT) : cout << "The product of " << first_num << " and " << second_num << " is " << first_num*second_num << ".\n"; ----- HTH.
__________________
words to live by: others don't know, I know. others know, I know more. others know more, I excel. one shouldnt read this far; above, is meant as an encouragement, translated from a Chinese Proverb. "He who angers you conquers you." : Elizabeth Kenny Last edited by alfie2; 02-08-2006 at 04:22 AM. |
|
|
|
|
|
#6 |
|
Member (6 bit)
Join Date: Feb 2006
Location: MA
Posts: 43
|
#include <.iostream>
Int main() { Int first_num; Int second_num; cout << "Enter an integer between 1 and 10: "; cin >> first_num; cout << "\n\nEnter second number: "; cin>> second_num; cout << "The product of " << first_num << " and " << second_num << " is " << first_num*second_num << ".\h"; cout << "The sum of " << first_num << " and " << second_num << " is " << first_num+second_num << ".\h"; exitcomm(); } void exitcomm(){ cout << "Press enter to exit..."; getchar();getchar();} Hope this help. This is how it should look like... pretty basic. But, I do tend to make a lot of mistake in basic coding. --.h is correct, it's a form of a standard string... correct me if i am wrong --you need to include --add a function at the end calling the exit method |
|
|
|
|
|
#7 |
|
Member (9 bit)
|
Thank You.
|
|
|
|
|
|
#8 |
|
Member (9 bit)
Join Date: Feb 2005
Posts: 392
|
nav:
what does "\h" do? in my 20 years of programming, I never hear of it. "\n" is end of line, but "\h" simply prints an "h" at the end of the sentence without producing a new line, so the next "cout" statement will be printed appeneded to it. lets refresh: In C\C++ Escape Sequence Represents \a Bell (alert) \b Backspace \f Formfeed \n New line \r Carriage return \t Horizontal tab \v Vertical tab \' Single quotation mark \" Double quotation mark \\ Backslash \? Literal question mark \ooo ASCII character in octal notation \xhhh ASCII character in hexadecimal notation |
|
|
|
|
|
#9 |
|
Member (6 bit)
Join Date: Feb 2006
Location: MA
Posts: 43
|
Alfie2 you might be right on that one. If you have done coding for 20 years... I take your word and judgment on it.
From my knowledge .h itself is an extension... i.e. stdio.h, which is use in a standard i/o. Let's just leave it at that, it was my poor judgment to overlooked the codes. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|