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

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.

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

Attachments
# include <iostream>

using namespace std;

int main()

{
	switch (letter)
{
  case 'A': cout << "ALPHA";      // do something
            break;
  case 'B': cout << "Bravo";      // do something
            break;
  case 'C': cout << "Charlie";
			break;
  case 'D': cout << "Delta";
			break;
  case 'E': cout << "Echo";
			break;
  case 'F': cout << "Foxtrot";
			break;
  case 'G': cout << "Gulf";
			break;
  case 'H': cout << "Hotel";
			break;
  case 'I': cout << "India";
			break;
  case 'J': cout << "Juliet";
			break;
  case 'K': cout << "Kilo";
			break;
  case 'L': cout << "Lima";
			break;
  case 'M': cout << "Mike";
			break;
  case 'N': cout << "November";
			break;
  case 'O': cout << "Oscar";
			break;
  case 'P': cout << "Papa";
			break;
  case 'Q': cout << "Quebec";
			break;
  case 'R': cout << "Romeo";
			break;
  case 'S': cout << "Sierra";
			break;
  case 'T': cout << "Tango";
			break;
  case 'U': cout << "Uniform";
			break;
  case 'V': cout << "Victor";
			break;
  case 'W': cout << "Whiskey";
			break;
  case 'X': cout << "X-ray";
			break;
  case 'Y': cout << "Yankee";
			break;
  case 'Z': cout << "Zulu";
			break;
  default : cout << "Error";
}

    
    
	return 0;
}

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

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.

This article has been dead for over six months. Start a new discussion instead.