[Courses] re: [C] lesson 7

Bidea Cristian phaser_programmer at yahoo.com
Wed Nov 6 04:50:31 EST 2002


OK Teo! First of all I think that you are wrong when you say that "hardcoding a boolean self-defined....make the program look a little more confusing". The boolean data type is included by default in many programming languages. If the boolean data type exist by default in other programming languages, it means that this can help the programmer, it means that the programmer needs boolean data type :). Defining a new data type makes the program easy to read (in most cases) and to understand because any integer variable can have value 1 or 0 but not any variable can have the value "true" or "false". In a big a program when you say i = 1 or  i = true, matters because when other people see "i = true" understand that i is a variable that is used like a boolean variable... 
This is my opinion! I was only giving an advice... not a rule :) 
OK! Bye! Peace :)  
 Eugene Teo <eugene.teo at eugeneteo.net> wrote: There isn't a need to do a symbolic constant for boolean.
Just remember that if it is 0, then it is false. Anything else is true.

Hardcoding a boolean self-defined type would only make the program look
a little more confusing than required later on.


u> 
u> 
u> I don't know if this is absolutely necessary, but I want to make some observations:
u> 
u> 
u> It seems that the C programming language doesn't have BOOLEAN,
u> in it like Pascal does. In Pascal, the Boolean data type returns
u> true or false. So, using the Boolean type, Pascal programmers
u> can create functions (procedures) like: isvowel(ch), or isdigit(ch).
u> --------------------------------
u> 
u> OK! Is true, in C there is no boolean data, but (there is but :-) you can simulate the boolean data. The boolean data is practically an integer data type that can have only two values 0 and 1. But in other languages you can say "true" instead of 1 and "false" instead of 0. You can do this this in C with the #define directive:
u> 
u> #define boolean int
u> 
u> #define false 0
u> 
u> #define true 0
u> 
u> Or in C++ with
u> 
u> typedef enum boolean{false, true};
u> 
u> OK! That's all! Bye! Peace :)
u> 
u> -----------------------------



---------------------------------
Do you Yahoo!?
HotJobs - Search new jobs daily now-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://linuxchix.org/pipermail/courses/attachments/20021106/e8d6d664/attachment.xhtml


More information about the Courses mailing list