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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:15:23+00:00 2026-05-23T08:15:23+00:00

I have an if statement that looks as follows: int count=0; string Check; if

  • 0

I have an if statement that looks as follows:

int count=0;
string Check;

if ((count==4 && Check!="-s")||(count==4 && Check!="-S"))

If count equals 4 and Check equals "-s" or "-S" it still enters this if statement because of the count == 4. It totally seems to ignore the second part. Is there something I’m doing wrong?

  • 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-05-23T08:15:24+00:00Added an answer on May 23, 2026 at 8:15 am

    Well, if Check is "-S", then it will not even check the second pair of conditions, because you check with ||. The same holds true for the opposite case. If one is false, the other is true. Replace that with a &&.

    int count = 4;
    string Check = "-S";
    
    if( (count == 4 && // count is 4, alright.
         Check != "-s") || // Check is "-S", alright I'm done thanks to || (OR)
        (count == 4 &&
         Check != "-S") )
    {
      // ...
    }
    
    int count = 4;
    string Check = "-s";
    
    if( (count == 4 && // count is 4, alright.
         Check != "-s") || // Check is "-S", time to check the other condition pair...
        (count == 4 && // count is 4, alright.
         Check != "-S") ) // Check is "-s", which is different from "-S", perfect.
    {
      // ...
    }
    

    Now the corrected version:

    int count = 4;
    string Check = "-S";
    
    if( (count == 4 && // count is 4, alright.
         Check != "-s") && // Check is "-S", different from "-s", now on to the other condition!
        (count == 4 && // count is 4, alright.
         Check != "-S") ) // Check is "-S"... oh dang! No executed code for you.
    {
      // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a for each statement that looks for a Taxonomy by ID and
I have an if statement that needs to look like this: UPDATE $(input#textbox).keypress(function(e){ key==e.which;
I have a sql statement that uses Difference => http://msdn.microsoft.com/en-us/library/ms188753.aspx I do this in
I have a collection of data that looks as follows: id name c1 c2
So I have a text file called maze.txt that looks like this: ############### Sacbifnsdfweovw
I have a servlet that calls MySQL database. The deletePage method looks like this:
I have a view that is working completely fine, and looks roughly as follows:
I have a case statement that returns a date; case when (ma.first_active_date is not
I have a sql statement that concatenates two columns, ItemNumber and Name, into one
I have an UPDATE statement that's intended to update a status field for a

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.