|
-
whats wrond with the following C++ code...
#include<iostream.h>
int main ()
{
int earn;
cin>>"Enter your wage";
if (earn<6000);
cout<<"You dont pay tax"<<endl;
if ((earn>5000) && (earn<20000));
cout<<"You have to pay 20%"<<endl;
if (earn>=20000);
cout<<"You pay 90%"<<endl;
}
i get two errors. whats wrong wid the code
* Mesh ATX MIDI Tower Case + 300W PSU
* Athlon DDR 333MHZ Motherboard (Onboard sound)
* AMD Athlon XP 2200+ CPU (266MHZ)
* 512MB (2 x 256MB) PC2100 DDR MEMORY (266MHZ)
* 120GB Ultra Fast (7200rpm) HD with 2mb Buffer
* 1.44 MB Floppy Disk Drive
* Teac 40 x 12 x 48 IDE CD-RW
* 128 MB NVIDIA GFORCE4 TI 4200 + TV out & DVI
* 19" Hansol Digital Monitor 0.26mm
* Logitech Navigator Cordless Keyboard & Mouse
* 16x LG DVD ROM Drive
* Creative Sound Blaster AUdigy W/SB1394 (Firewire)
* 56kbs Modem
* Creavite Labs Inspire 5300 Five Point Surrounds
* Lexmark X83 Printer (All in one)
-
RIP SiS :(
What errors?
I'm not really into programming anymore, but I assume this info would help the programming gurus answer your question.
-
here is the complete list of errors that i got when i tried compiling the program:
************************************************************ ********
Linking...
calcutaing salary.obj : error LNK2005: _main already defined in book practise.obj
Debug/Book practise.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
* Mesh ATX MIDI Tower Case + 300W PSU
* Athlon DDR 333MHZ Motherboard (Onboard sound)
* AMD Athlon XP 2200+ CPU (266MHZ)
* 512MB (2 x 256MB) PC2100 DDR MEMORY (266MHZ)
* 120GB Ultra Fast (7200rpm) HD with 2mb Buffer
* 1.44 MB Floppy Disk Drive
* Teac 40 x 12 x 48 IDE CD-RW
* 128 MB NVIDIA GFORCE4 TI 4200 + TV out & DVI
* 19" Hansol Digital Monitor 0.26mm
* Logitech Navigator Cordless Keyboard & Mouse
* 16x LG DVD ROM Drive
* Creative Sound Blaster AUdigy W/SB1394 (Firewire)
* 56kbs Modem
* Creavite Labs Inspire 5300 Five Point Surrounds
* Lexmark X83 Printer (All in one)
-
not suppose to have ";" after the if statement.
-
no use, i removed the ";" sign but its of no use, i still get the same errors.
* Mesh ATX MIDI Tower Case + 300W PSU
* Athlon DDR 333MHZ Motherboard (Onboard sound)
* AMD Athlon XP 2200+ CPU (266MHZ)
* 512MB (2 x 256MB) PC2100 DDR MEMORY (266MHZ)
* 120GB Ultra Fast (7200rpm) HD with 2mb Buffer
* 1.44 MB Floppy Disk Drive
* Teac 40 x 12 x 48 IDE CD-RW
* 128 MB NVIDIA GFORCE4 TI 4200 + TV out & DVI
* 19" Hansol Digital Monitor 0.26mm
* Logitech Navigator Cordless Keyboard & Mouse
* 16x LG DVD ROM Drive
* Creative Sound Blaster AUdigy W/SB1394 (Firewire)
* 56kbs Modem
* Creavite Labs Inspire 5300 Five Point Surrounds
* Lexmark X83 Printer (All in one)
-
Well, I believe you have a few errors. First of all, the semicolons on the if statements. Second, the cin operator does not output code. You should have written:
cout << "Enter your wage: ";
cin >> wage;
Also, your main functions is declared as an integer type. Therefore, the function MUST return a value. Try sticking a return 0 statement at the end of your code. That should work.
-
Hammerhead Shark
return 0;
to be exact.
anyway, have u tried getting a compiler that tells u what kind of error its getting? i like visual c++ and ive also used codewarrior. that one will tell u if its a delaration syntax error, ; expected before statement, etc. both are quite nice, try out each one, and consider puyrchasing the one u like the most.
Specs:
Hercules Prophetview 920 17" LCD of *** kicking
WIN XP Pro of *** kicking
P3 733 @ 792
384 MB Crucial CAS 3 RAM
Geforce 4 4200 64 MB of *** kicking
Lite-On 48x12x48 CDRW of *** kicking thanks so some firmware updates
SB LIVE! Value
Altec Lansing ACS 54W
Soyo 7KCA+ or something like that
-
Catfish
Fixed (I believe):
#include <iostream.h>
//#include <stdafx.h> /* This header file is needed in Visual C++ as far as i know, if you're not using it just leave it commented*/
int main ()
{
int earn=0;
cin >> "Enter your wage";
if(earn<6000)
cout << "\nYou dont pay tax" << endl;
if((earn>5000) && (earn<20000));
cout << "\nYou have to pay 20%" << endl;
if(earn>=20000)
cout << "\nYou pay 90%" << endl;
return 0;
}
/*Try and use more spaces in your coding, it will help a lot and remember to define your variables by giving them a value*/
[-Personal Rig-]
EP-8k5a2+
AMD Athlon XP 2200+
512mb pc2700 DDR RAM
80gb WD "SE" HDD
40x Liteon CD-RW
19' Trinitron p991 FD Monitor
Sapphire Radeon 9700 Pro
Cable (RR)
Windows XP Pro
------------------
-
Great White Shark
Next time try posting your Question HERE!!
War... War never changes.
-
Cartoon Shark
Originally posted by binjured
//#include <stdafx.h> /* This header file is needed in Visual C++ as far as i know, if you're not using it just leave it commented*/
Nope you don't have to include it not in the last few versions I've used any way.
#Download Firefox# Playing: TF2
[Main Rig]
[EVGA P55 SLI] [i7 860 @ 3.6] [Cooler Master Hyper 212 Plus] [8GB Corsair DDR3 1600]
[Intel G2 80GB SSD] [MSI GTX260 OC] [NEC ea231wmi] [X-Fi > Z-Audio Lambda > Senn HD-580s]
[Server]
[MSI K8N Neo4 SLI] [Opteron 175 @ 2.9] [TT Big Typhoon] [2GB Corsair DDR]
-
Try this
Try this, looks like it should work.
#include<iostream.h>
int main ()
{
int earn = 0;
cout << "Enter your wage: ";
cin >> earn;
if (earn<6000)
cout<<"You dont pay tax."<<endl;
if ((earn>5000) && (earn<20000))
cout<<"You have to pay 20%."<<endl;
if (earn>=20000)
cout<<"You pay 90%."<<endl;
return 0;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|