473,385 Members | 1,372 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,385 software developers and data experts.

evaluates to true

how do I write this out? If I type the word "true" it keeps rejecting it.... ??
Once again, this is intro level so it should be very easy



Write an expression that evaluates to true if and only if the value of the boolean variable workedOvertime is true.
Sep 18 '06 #1
3 23729
Let us suppose that 1 is true and 0 is false and accordingly you change the status of a variable and check for true or false.
Sep 19 '06 #2
D_C
293 100+
That is a bidirectional implication. Suppose our conditional statement is C(workedOvertime).

When workedOvertime is true, C(workedOvertime) is true. Also, the contrapositive is true. When C(workedOvertime) is false, workedOvertime is false. True and false are the only two possible values, so for all cases C(workedOvertime) is equivalent to workedOvertime.

It's like saying write a function f(x) such that it's output is equivalent to it's input. In that case, f(x) = x.
Sep 19 '06 #3
Banfa
9,065 Expert Mod 8TB
If I type the word "true" it keeps rejecting it.... ??
You mean you get compiler errors?

There is no keyword "true" (or "false") in a lot of C compilers (although I believe it was added to the standard in C99 many compilers still only support C89).

In C the terms true and false are normally appilied to integer expressions (having type char, short, int, long). In this instance a value of 0 is false and any other value is true

e.g. for a char variable

0 = false
1 - 255 = true

Logical expressions (== <= > etc) return 0 or 1. Many (most even) developments end up defining a boolean type, this is normally either an enum or a typedefed integer with #defined true and false values

Expand|Select|Wrap|Line Numbers
  1. typedef char boolean;
  2. #define FALSE  0
  3. #define TRUE   1
  4.  
  5. typedef enum tag_bool {
  6.   false = 0,
  7.   true  = 1
  8. } bool;
  9.  

Whether an expression is treated as a boolean expression or not depends entirely on the context it is used in.



in C99 and C++ there is a bool type defined in the languagewith takes values true and false. In this case bool, true amd false are keywords of the language.
Sep 20 '06 #4

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

Similar topics

3
by: Eric Linders | last post by:
Hello, We have a form that is collecting user input. There are three fields for each phone number (area code, prefix and suffix). I'm trying to use a simple if statement to confirm if the first...
3
by: Jim Ley | last post by:
Hi, It seems the mozilla guys have chosen another (almost certainly poor choice in my initial thoughts) of having document.all evaluate to false, but document.all catch the chicken event - also...
1
by: mg | last post by:
Is there a simple way to evaluates a supplied string as though it were code (C# in code behind). For example, eval ("int5.ToString()")? If so, could you show me how?
1
by: Erik Tamminga | last post by:
Hi, I'm totally bluffed: how can a 'public const string name = "myname";' ever evaluate to null? I have the following class: public class MIB2 { public const string org = "1.3";
4
by: TS | last post by:
I have this simple equation that returns a boolean: if( ti.NumberIncorrect > (TotalQuestions - (TotalQuestions * FailurePercentage) )) ti.NumberIncorrect is int : 4 TotalQuestions is int :...
0
by: mg | last post by:
Is there a simple way to evaluates a supplied string as though it were code (C# in code behind). For example, eval("Server....") ?
0
by: peter.bittner | last post by:
I have developed a Windows application in Visual Studio .NET 2003 and created a Setup project for it. In the File System Editor I have added a shortcut to the User's Desktop folder to point to the...
1
by: David | last post by:
I inherited an excel macro that compares two different worksheets and matches rows from worksheet 2. I created a module that would let me know if there are any duplicates in worksheet 2. The...
1
by: dbenavides | last post by:
also, if something evaluates to non zero in c++ is it true or false?
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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.