Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

SM10403

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?

INT DATA TYPE:


Integer variable are variable that can only have values of whole numbers and can be declare by using the data type with keyword int. Int data type is used to represent integer between -2147483648 and 2147483648 (32bits).

BOOL DATA TYPE


Boolean is an expression that can be thought of as being true or false. In fundamental C++, any non-zero value true zero false

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.

You might also like