Menu

help in switch

2007-08-15
2012-09-26
  • Nobody/Anonymous

    h! hope u can help me with my asignment...
    example this is the program

    char q;
    cout<<"Enter a letter";
    a=getch();
    switch(q)
    {
    case 'A':
    cout<<"Apple";
    break;
    }
    now this is my question: how to swap big letter A to small letter a...when you run the program if u don't press the capslock you will input a small letter "a"...ryt? so ders a logic eror...
    aside from puting
    if (q='a')
    {q='A';}
    before the switch...
    and make another case like case 'A':
    cout<<"Apple";
    break;
    case 'a':
    cout<<"Apple";
    break;
    What other syntax can be use?
    Hope someone will help me hhehehe...thanks!...

     
    • andy`

      andy` - 2007-08-16

      nice one thank you for the information that u gave...this will help me...

       
    • Osito

      Osito - 2007-08-15

      I think you could do switch(tolower(q))and then have case 'a': instead. Or just stack multiple cases.

      case 'a': case 'A':
      cout << "Apple";

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.