:confused: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?

Recommended Answers

All 11 Replies

switch(value)
{
  case possibleValue1:
    // do something
    break;
  case possibleValue2:
    // do something
    break;
  /* ... */
  default: // value wasn't any of possibleValue[1,n]
    // do something
}

Post some code, or some sort of attempt if you want more help ;)

what do you mean by do something is that the alpabet word like Alpha
for the A character if it was entered?

use something like this:

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

and repeat for all the letters.

That's icky, but it's a start.

How about you post an attempt, wheelz?

Member Avatar

One quick solution would be to create a parallel array.

array one =
[ "a",
  "b",
 
]
 
array two =
[ "alpha",
  "bravo",
]

Then you match each by their corresponding index offset.

:confused: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?

This is what I have so far but it still doesn't work! I don't have a clue of what or how I am to start this program:confused: 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

char letter;
cin>>letter;

I add The
char letter;
cin>>letter;

and now I have a fatal error C1010 unexpected end of file
while looking for precompiled header directive

Member Avatar

I add The
char letter;
cin>>letter;

and now I have a fatal error C1010 unexpected end of file
while looking for precompiled header directive

Did you change anything else?

not that I know of!!!!

I must be really screwing this up bad A.....

That error looks like you've got a Visual C++ project expecting a precompiled header (VC++ usually calls it "StdAfx.h" or something, IIRC). I havent used VC++ in a long time, but you'll probably have to recreate your project to not expect that. The code seems to work fine for me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.