Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9258017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:17:14+00:00 2026-06-18T12:17:14+00:00

On an example I am working on, I have code to pick out the

  • 0

On an example I am working on, I have code to pick out the vowels between ‘a’ to ‘z’. It is using a switch statement that instead of separate cases, the character values are sharing the same case. From what I know so far, the expression involved i.e

***(letter * (letter >= 'a' && letter <= 'z'))*** 

evaluates to true or false and is converted to an integer (1 and 0) in which it falls through to “case 0:” (0 obviously being false) to deal with the result should it be false. Can anyone explain the expression to conversion process involved with this statement? particularly the reasoning behind the multiplication of the logical expression. Here is my example code:

char letter(0); 
cout << endl
     << "Enter a small letter: ";
 cin >> letter;

switch(letter * (letter >= 'a' && letter <= 'z'))
{
case 'a': case 'e': case 'i': case 'o': case 'u':
    cout << endl << "You entered a vowel.";
    break;

case 0:
        cout << endl << "That is not a small letter.";
        break;

    default: cout << endl << "You entered a consonant.";
}

EDIT: All great answers guys. Cleared a lot up. Thanks again for your input

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:17:16+00:00Added an answer on June 18, 2026 at 12:17 pm
    letter * (letter >= 'a' && letter <= 'z')
    

    The conditional expression multiplicand will evaluate to a true or false. The ASCII value of letter will be compared to the characters “a” and “z”. True and false can be implicitly-converted to the numerals 1 and 0 respectively (and letter will be converted to its numeric ASCII value). So it will either be:

    letter * (0)
    

    or

    letter * (1)
    

    Anything times 0 is 0 which means without a corresponding case the control will go down to the default case (this one goes down to the case: 0 part). Otherwise, letter * (1) is letter, and therefore it will be compared by the other cases as if it were switch (letter).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone have a working example of a video player built using Qt phonon?
Does anybody have an example of working with database using Visual C++ and OLEDB?
Sorry for repost but I have a better working example of data that reflects
I'm currently working on the interesting example in cocos2d. I have a sprite, that
So I have code like this: $(.list).append('<li>hi</li>'); Here's a working example: http://jsfiddle.net/pXaSC When you
I have a code that was working until iOS 4.3.5, now in iOS 5
Can I get some working code examples that I can pick apart and study
I have working code that will upload photo from form. However when I do
I have been working on information extraction and was able to run standAloneAnnie.java http://gate.ac.uk/wiki/code-repository/src/sheffield/examples/StandAloneAnnie.java
Does anyone have a working example of OAuth authentication for twitter with Android? I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.