Page 248 - Computer_Science_F5
P. 248

Derived data types
              These are data types derived from primary data types. Derived data types are array,
              function, pointer, and reference.


              User-defined data type                                                               Chapter Four: Object oriented programming with C++
          FOR ONLINE READING ONLY
              These are data types defined by the user. Such data types can determine the state
              of the data, whether public, private, or protected. User-defined data type includes
              structure, union, enumeration, and classes.


                 Activity 4.2:

                Identifying data types from a program


                     #include<iostream>
                     #include<iomanip>
                     using namespace std;
                     void printMonth(int year,int month);
                     void printMonthTitle(int year, int month);
                     void printMonthName(int month);
                     void printMonthBody(int year, int month);
                     int getStartDay(int year, int month);
                     int getTotalNumberOfDays(int year, int month);
                     int getNumberOfDaysInMonth(int year, int month);
                     bool isLeapYear(int year);
                     int main()
                     {
                           int year, month;
                           cout<<”Enter full year: “;
                           cin>>year;
                           cout<<”Enter month in number between 1 and 12: “;
                           cin>>month;
                           cout<<endl;
                           printMonth(year, month);
                           cout<<endl;
                           cout<<endl;
                           return 0;
                     }


                Questions:
                1.  Identify all data types applied in a program.
                2.  Write the role of each data type you have identified in (a).


                                                    239
               Student’s Book  Form Five



     Computer Science Form 5.indd   239                                                     23/07/2024   12:33
   243   244   245   246   247   248   249   250   251   252   253