473,378 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Little help with this if statement

I trying to make it so letter1 and letter2 must be c, C,q or Q, but this code is not working because basically when I have a c, its not a q or a Q so the if statement would take into place. What code would I put in that would check for all 4 instances?

Expand|Select|Wrap|Line Numbers
  1.  
  2. if (letter1 != 'c' || letter1 != 'C' || letter1 != 'q' || letter1 != 'Q')
  3.     {
  4.         cout << "AYE" <<endl;
  5.         x = 0 ;
  6.         x = 0; 
  7.     }
  8.     if (letter2 != 'c' || letter2 != 'C' || letter2 != 'q' || time_period2 != 'Q' )
  9.     {
  10.         cout << "AYE" <<endl;
  11.         x = 0
  12.         y = 0; 
  13.     }
  14.  
-Jeff
Mar 26 '08 #1
1 1010
Laharl
849 Expert 512MB
You've got the wrong logical operator. You don't want it to be OR, since that returns true if one of the statements is true. You only want it to return true if both are true. What logical operator is that?
Mar 26 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: hicham | last post by:
Hi, I am looking for help, i would like to know how can i use the endian.h and config.h to convert compiled files under solaris from BIG-ENDIAN to compiled files LITTLE-ENDIAN. I am working...
6
by: cppaddict | last post by:
It struck me as odd today that while class definitions require a semi-colon at the end, function definitions do not. I was curious if this small syntactic difference represents a larger conceptual...
7
by: rkrueger | last post by:
Given the following 3 Tables: CREATE TABLE ( NOT NULL , NOT NULL CONSTRAINT DEFAULT (getdate()), NULL , CONSTRAINT PRIMARY KEY CLUSTERED (
1
by: D. Shane Fowlkes | last post by:
I have a form in which clicking the submit button calls a "SaveData" sub rountine I wrote. The SaveData rountine inserts data from the form into a table and grabs the ID of the newly inserted...
1
by: Tim O'Donnell | last post by:
Most of you hardcore developers may already know this, but I don't think everyone does so here goes... When debugging code we all used to placing our mouse over an object or variable to reveal...
3
by: Mark Kirkwood | last post by:
This caught me today : I switched on "log_statement=true" whilst examining a possible foreign key concurrency problem. I noticed that the generated foreign key check "SELECT 1 FROM ONLY ......
6
by: sparks | last post by:
extracalc = Switch(Me.Parent.Race_Black = -1 And Me.Parent.Sex = "Female", 1.952, Me.Parent.Race_Black = -1, 1.21, Me.Parent.Sex = "Female", 0.742, 1) I look at this and say ok if race = black...
54
by: ash | last post by:
i am writing this program (for exercise1-9 in k&r-2nd edition) which removes extra spaces in string example- "test string" will be "test string" #include<stdio.h> #include<string.h>...
16
by: mdh | last post by:
Can someone look at this little program and tell me why the last line is not compiling. #include <stdio.h> int main (){ int i, j, k; i=0;
3
by: Ethan Furman | last post by:
len wrote: I've never had the (mis?)fortune to work with COBOL -- what are the files like? Fixed format, or something like a dBase III style? I
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.