Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 86,374 C++ Programmers. There are 1,418 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a C++ Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

Need help with if statement

 
Reply to this topicStart new topic

Need help with if statement

warchilo
post 8 May, 2008 - 09:19 AM
Post #1


New D.I.C Head

*
Joined: 15 Jan, 2007
Posts: 12



Hello guys, I'm trying to revise for a basic programming test next week and I have hit a brick wall with one of the example programs. Basically I have an if statement with two conditions to check but the second condition isn't getting checked so the program isn't entering the if statement and the result is an answer I dont want.

CODE

if ((DaysSinceDebited[counter]<30)||(Balance[counter]<1000))
        {
            interest = ((Balance[counter]/100)*3);
        }


the problem I am having is that the the second part isn't being checked so if the first part doesn't come up true the if statement is being ignored. Any help would be appreciated as I have been trying to do this for hours now. If you need more of the code to help me out let me no and I'll put it straight up.

Thanks.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


realNoName
post 8 May, 2008 - 09:56 AM
Post #2


D.I.C Head

**
Joined: 4 Dec, 2006
Posts: 208

so you need both conditions to be true? if so then you need to use and 'and' not 'or'

CODE
if ((DaysSinceDebited[counter]<30) && (Balance[counter]<1000))
        {
            interest = ((Balance[counter]/100)*3);
        }
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

warchilo
post 9 May, 2008 - 01:53 AM
Post #3


New D.I.C Head

*
Joined: 15 Jan, 2007
Posts: 12

QUOTE(realNoName @ 8 May, 2008 - 09:56 AM) *

so you need both conditions to be true? if so then you need to use and 'and' not 'or'

CODE
if ((DaysSinceDebited[counter]<30) && (Balance[counter]<1000))
        {
            interest = ((Balance[counter]/100)*3);
        }



Thank you, I keep making simple errors like this. you wouldn't believe the amount of time i wasted trying to use 'or'.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
Time is now: 5/17/08 02:52AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month