|
-
Feb 7th, 2001, 10:56 PM
#1
Thread Starter
Hyperactive Member
Alright. I am real new at C++ and have a simple bracket { question.
I am not sure of the placement in a nested if, else if statement. Please help!
Here is an example...It gives the same response no matter what number you enter, although I don't know why:
#include <iostream.h>
void main()
{
//declare and initialize variable
short code = 0;
//get code from user
cout << "Enter the code (1 through 5): ";
cin >> code;
//display salary
if (code = 1)
cout << "$45,000" << endl;
else
if (code == 2 || code == 5)
cout << "$33,000" << endl;
else
if (code == 3 || code == 4)
cout << "$25,000" << endl;
else
cout << "Entry error" << endl;
//end if (code == 3 || code == 4)
//end if (code == 2 || code == 5)
//end if (code == 1)
} //end of main function
 Mahalo 
VB6(SP5), VC++, COBOL, Basic, JAVA
MBA, MCSD, MCSE, A+
Computer Forensics
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
|
Click Here to Expand Forum to Full Width
|