Professional Documents
Culture Documents
Object-Oriented Programming Lecturer: Madam Salina Binti Sulaiman
Object-Oriented Programming Lecturer: Madam Salina Binti Sulaiman
Group member 3:
CHONG SHEAN YUAN LAI WAI NAM MOHD. AZAM NUR AISYAH BT. ABU BAKAR SHAMAN BT. MERAN SHIRLEY LAI FUNG MUI SYLEVESTER JIUL YEO JUN ZHAO YONG ANN PENG
Question :
What are the advantages and disadvantages to using the int data type rather than the bool data type to manipulate Boolean expression? Why do student think int data type is still used for Boolean expression?
Bool data type is for test logical expression with the operators such as !(not), &&(and) and ||(or).
Int data type has wider range of number to be converted into true and false compare to bool data type.
Int data type represented by 4 bytes in storage but bool data type represented by a single byte. Bool type cant accessed efficiently on many machines they often store in the smallest efficiently addressable cell of memory typically a byte.
Int data type are more readable compare to bool type as the bool type which using symbol operators.
Bool can only used for logical expression which consists of two option (true or false). So bool data type is not suitable to solve a complicated problem.
Bool data type more suitable to solve some simple programme where need to represent switches and flags. For example, When we need to ask the user with the question yes or no or (y/n), the answer sure will be y or n which is a character and it cant be hold by int data type.
Student think int data type is still use for Boolean expression as student are more familiar with int data type. True and false in logical expression will evaluate to 1 and 0 which is integer, so student like to used int data type to manipulate logical (Boolean) expressions.