| | |
Need help writing a switch program for class
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
C++ Syntax (Toggle Plain Text)
switch(value) { case possibleValue1: // do something break; case possibleValue2: // do something break; /* ... */ default: // value wasn't any of possibleValue[1,n] // do something }
use something like this:
and repeat for all the letters.
C++ Syntax (Toggle Plain Text)
switch(tolower(letter)) { case 'a': cout << "Alpha"; // or return, if this is just a function break; // don't need this if you use return above
That's icky, but it's a start.
How about you post an attempt, wheelz?
How about you post an attempt, wheelz?
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
One quick solution would be to create a parallel array.
Then you match each by their corresponding index offset.
C++ Syntax (Toggle Plain Text)
array one = [ "a", "b", ] array two = [ "alpha", "bravo", ]
Then you match each by their corresponding index offset.
*Voted best profile in the world*
•
•
Join Date: Sep 2006
Posts: 13
Reputation:
Solved Threads: 0
•
•
•
•
I got this assignment to write a program using the switch statement or the functional decomposition, that inputs a letter and outputs thr corresponding international Alpabet.
A Alpha
B Bravo
C Charlie
so on and so on
Is there anybody that can help me with this program?
I don't even know how to put the code into this chat box so I just attached the file will that work?? Add this before switch
C++ Syntax (Toggle Plain Text)
char letter; cin>>letter;
The key to eliminating bugs from your code is learning from your mistakes.
![]() |
Similar Threads
- summation program (C++)
Other Threads in the C++ Forum
- Previous Thread: problem using wingdi.h in bcc 5.5
- Next Thread: c++ File I/O Help
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count database delete deploy developer dll download dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph gui homeworkhelp iamthwee ifstream image input int java lib library linker list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






