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 9217549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:39:28+00:00 2026-06-18T02:39:28+00:00

Slight issue. (Not using toupper() and tolower() functions) I understand what converting to uppercase

  • 0

Slight issue. (Not using toupper() and tolower() functions) I understand what converting to uppercase and lowercase using numerical values is but following my C++ book, why is the conversion at the end of this statement and not before?:

if (letter >= 'A')  //test for 'A' or larger
    if (letter <= 'Z')  //test for 'Z' or smaller
    {
        cout << endl
             << "You entered a capital letter."
             << endl;
        letter += 'a' - 'A'; //Convert to lowercase
        return 0;
    }

if (letter >= 'a') //test for 'a' or larger
{
    if (letter <= 'z') //test for 'z' or smaller
    {
    cout << endl
         << "You entered a small letter."
         << endl;

    return 0;
    }
}

Why would it convert the uppercase to lowercase at this point of code execution since the second if statement deals with lowercase 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-18T02:39:29+00:00Added an answer on June 18, 2026 at 2:39 am

    Why would it convert the uppercase to lowercase at this point of code
    execution since the second if statement deals with lowercase input?

    That is because

    return 0
    

    means that the function is finished. The lines

    if (letter >= 'a') //test for 'a' or larger
    {
        if (letter <= 'z') //test for 'z' or smaller
        {
        cout << endl
             << "You entered a small letter."
             << endl;
    
        return 0;
        }
    }
    

    will not be executed if letter was originally an upper case letter. It would print out “You entered a capital letter.”, then convert it to lower case, then exit.

    why is the conversion at the end of this statement and not before?

    It would make no difference if the conversion were before the cout statement.

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

Sidebar

Related Questions

I am using MVC 2, and having a slight issue with the ActionLink not
First of all: I'm at Scala 2.8 I have a slight issue while using
I'm having a slight issue and not quite understanding the syntax for what I'm
While converting from RSpec to Minitest I ran into a slight issue that Google
We've got a slight performance issue in a section of code that's using LINQ
I have a slight issue when i get content using ajax. The issue is
I know this is not supported in UIData and I understand why, but this
I am having a slight issue with validation in struts2 during consecutive validations.Now if
I have a slight issue where I can't seem to select a User Control
Hi i'm having a slight issue with a OneToOne relationship which when runs the

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.