Page 246 - Computer_Science_F5
P. 246
(a) Identify all errors in the program.
(b) Correct errors before running the program.
(c) Run the program and display the results.
2. Describe five (5) characteristics of a good program. Chapter Four: Object oriented programming with C++
FOR ONLINE READING ONLY
3. Will the following lines of code in (a) and (b) print the same thing? Explain
why or why not.
(a) cout << 5 << ‘\n’;
(b) cout << “5” << ‘\n’;
4. Will the following lines of code print the same thing? Explain why or why not.
(a) cout << y<< ‘\n’;
(b) cout << “y” << ‘\n’;
Data types
C++ programming language supports various types of data. Each data type defines
its memory size, and improves the running speed of the program. C++ programming
language provides different types of data based on numeric values, Boolean values,
and characters under a specific range of values. C++ programming language is
based on three categories of data types as shown in Figure 4.23. These are built-in
or primary data types, user-defined data types, and derived data types.
Data types
Built-in/primary Derived User defined
Figure 4.23: Fundamental data types in C++
Built-in or primary data types
Built-in or primary data types are pre-defined data types that can be applied directly
without creating them. Built-in data types include Integer, Character, Float, and
Bool.
(a) Integer data types
Integer data types involve whole number. Integer data types include, signed integer,
unsigned integer¸ short integer, unsigned short integer, and long integer. Table 4.3
shows the classification of integer data types with their storage size and range.
237
Student’s Book Form Five
Computer Science Form 5.indd 237 23/07/2024 12:33

